Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In run method threade name is:main
In main method thread name is:main

Don't understand where is t1 ?
 
Chan Ag
Rancher
Posts: 1089
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't start a thread ( as a separate task ) by invoking the run method directly on the thread object. We invoke the start() method on the thread object. The start() method is in the Thread class and it invokes the run() method we override in our implementation.

Try invoking the start method on your thread object and see what output you get?

Chan.

Edit : Since you have invoked run method directly, you have effectively not started a new thread and hence the thread that is executing the run() method is still the main thread. A thread ( a separate task ) begins when you invoke the start method on the thread object.
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh my lord i didn't observe carefully , i thought i m calling start method but it was run.
 
Winston Gutkowski
Bartender
Pie
Posts: 10111
56
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meeta gaur wrote:Don't understand where is t1 ?

Did you ask for its name?

I suggest you look carefully at the docs for currentThread(), and especially its signature - although I have to admit that the doc contents themselves aren't very helpful.

Winston
 
Winston Gutkowski
Bartender
Pie
Posts: 10111
56
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meeta gaur wrote:Oh my lord i didn't observe carefully , i thought i m calling start method but it was run.

Right. But it won't solve your basic problem, even if you call it right - at least, I'm pretty sure it won't.

You need to read my last post.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic