aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 357
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
 
Similar Threads
Thread Question
difference between start() and run() of a thread instance
Threads: differnece between start() and run()
Threads...
join()