This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Threads and Synchronization and the fly likes star() and run() in Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "star() and run() in Thread" Watch "star() and run() in Thread" New topic
Author

star() and run() in Thread

nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 371
When a Thread class is extended to create a thread, run() of Thread class is overridden. Does it mean that I don't need to use start() to start the thread and I can directly execute run() to start new thread ? OR do I still need to execute start() of Thread class, which in turn will execute run() of Thread class ?

Does it mean that no matter what, to start second stack for thread, its required to execute start(). If I execute run() without start(), then this run() will go on the same stack where main() is executed ?

Is start() only way to start a new stack or is there any other way also ?

Thanks
Khuzema Dharwala
Ranch Hand

Joined: Apr 26, 2010
Posts: 46

call to start() is required to create a separate thread of execution irrespective of whether you are extending a Thread class or implementing Runnable interface

you can test this scenario by calling static activeCount() method of Thread class which will return active threads in the current thread's thread group.

Thanks....


OCJP 6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: star() and run() in Thread