aspose file tools*
The moose likes Threads and Synchronization and the fly likes Not getting the output  of run method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Not getting the output  of run method?" Watch "Not getting the output  of run method?" New topic
Author

Not getting the output of run method?

upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 73



getting out put as
main thread started
then wait for 1sec and then
main thread started1.
Thanks
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

There is no instance of T1 created and calling the run() method.
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1512
    
    5

Raymond Tong wrote:There is no instance of T1 created and calling the run() method.

Correct. Besides, your class T1(why classname is T1? ) is not a thread or a Runnable.

What you are doing is:
Start a 'blank' thread - which actually does nothing:

Above code will call default run method of Thread class.

What you need to do is:
1) Create a class that extends Thread or implements Runnable
2) Override run method
3) Create a thread which accepts object of your thread/runnable implementation
4) Start the thread

I hope this helps.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not getting the output of run method?