Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread query!!!  RSS feed

 
Sonal Sharma
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we call the run method of the thread again through the same thread like let me elaborate upon my question:
1)We have a thread instance whose run method prints run... Can we print it twice.Does it have any relation to join method in anyway?
2)Through the thread object or class can we call any user-defined methods.What about the static methods?
3)What is the best book for Threads or any internet link anyone would be knowing for a deep understanding?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

One never calls run() on a Thread; the whole point of Thread is that it magically calls run() from a separate thread of execution. What you call is start().

Can you call start() twice on the same Thread object, and have it start again? No.

run() methods can call any other methods they'd like. Of course, they have to have access, be able to reach the target object, and watch out for concurrency issues.

The best book for Threads is Henry's.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!