File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes wat is the purpose of start() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "wat is the purpose of start()" Watch "wat is the purpose of start()" New topic
Author

wat is the purpose of start()

kotha vijaybabu
Ranch Hand

Joined: Jan 28, 2006
Posts: 77
hi ranchers...,

as v know dat start() is used to call run() implicitly...
it is also possible dat v call directly run()

then wat is the use of start()...

i mean to say dat wat is da difference when v call run() directly and with da use of start()

thanks in advance


vijay
Vinny Menon
Ranch Hand

Joined: Jan 10, 2006
Posts: 62

Hi Vijay
When we call run() directly ,it will execute in the main thread just a normal execution.
Where as when we call start(),it will execute on the separate thread that has been created by the user.
hth
Cheers
Vinny M


Regards,Vinny M.
proud Fan of European Champion CHELSEA FC
"If you don't see the bug where you're looking, perhaps you're looking in the wrong place" -James Gosling
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by Vinny Menon:
Hi Vijay
When we call run() directly ,it will execute in the main thread just a normal execution.
Where as when we call start(),it will execute on the separate thread that has been created by the user.
hth
Cheers
Vinny M


Almost. Invoking run() will not execute the code in the main thread, it will simply execute the code from whatever thread invoked it. This is not necessarily the main thread, but it could be. Furthermore, I think it's important to understand that start() is a native method that starts a new thread of execution. I think it would perhaps be more accurate to say it's a separate thread created by the JVM, not the user.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: wat is the purpose of start()
 
Similar Threads
How to run multiple processes at once, while still able to type commands to system.in
Thread
Bluetooth in java
Thread execution
Thread....