This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I think that we can also directly invoke the run method of the thread like so: myThread.run(); After all, the start method also simply calls run(), right? But look at this. This problem is from www.javacertificate.com
Which of the following statements are true? [Check all correct answers] 1 A thread is a different program. 2 A thread can share data with other threads. 3 A thread is started by calling the start method. 4 A thread is started by calling the run method.
javacertificate says only 2 and 3 are correct. I think 2 and 3 and 4 are all correct. This is what javacertificate.com says:
The only correct way to start a thread is calling the start method of the Thread class.
Do you people agree?
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
Why do you think that the start() method only executes the run() method? Did you actually take a look at the ocde that the start() method invokes? Here is the code: public synchronized native void start(); So there is obviously something else going on than just executing the run() method. In fact, there is a lot more going on. If you just run the run() method it does not create a separate thread. Only when you run the start() method does it create a separate thread.