Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

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
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!