The moose likes Java in General and the fly likes regarding thread run method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "regarding thread run method" Watch "regarding thread run method" New topic

regarding thread run method

rajareddy annavaarm
Ranch Hand

Joined: Mar 15, 2007
Posts: 96
Why cant we call run method in thread class directly?why we are calling it indirectly by start method?
rajaraman navaneethan
Ranch Hand

Joined: Feb 26, 2005
Posts: 86
Hi Rajareddy,
When you call the run method directly a separate call stack is not created and it runs as a part of the same call stack from the method which it is called.Eventually it doesnt run concurrently with other threads.

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Yes, the answer is that you can call run() method, just like any other method. But that runs it in the current thread. If you want to run it in another thread, you must use the API of Thread class to start a new thread, which will then call run() in the new thread.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: regarding thread run method
It's not a secret anymore!