aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding the start method of Thread Class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Overriding the start method of Thread Class" Watch "Overriding the start method of Thread Class" New topic
Author

Overriding the start method of Thread Class

Dhruv Arya
Greenhorn

Joined: Mar 30, 2009
Posts: 26


What happens in the above code ?? I m not able to understand the fact of overriding the start() method of the thread class and still get an output of MyThread: start() followed by MyRunnable:run() Please can some one explain thank you
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16695
    
  19

Dhruv Arya wrote:
What happens in the above code ?? I m not able to understand the fact of overriding the start() method of the thread class and still get an output of MyThread: start() followed by MyRunnable:run() Please can some one explain thank you


When you call, myThread.start(), you will get the "MyThread:start()" message.

When you call, thread.start(), the new thread will call the run() method of your runnable, and you will get the "MyRunnable:run()" message.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Byju Joy
Ranch Hand

Joined: Sep 06, 2005
Posts: 84
Runnable interface has only one method, public void run(). Even if the runnable object has a public void start() method, it doesn't get into picture. But the if Thread object has a public void start() it does come into picture and affect how thread is submitted for run.
Dhruv Arya
Greenhorn

Joined: Mar 30, 2009
Posts: 26
Thanks Alot I totally get my mistake you guys made my day Thank You
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding the start method of Thread Class
 
Similar Threads
Thread Question---start()
Thread Question
Problem in thread
Thread Doubt
Thread