Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

thread

 
Ranch Hand
Posts: 305
Tomcat Server Notepad 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 ?
 
Rancher
Posts: 1090
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
Tomcat Server Notepad 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.
 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE 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
Posts: 10777
71
Hibernate Eclipse IDE 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic