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

 
Malar Ravi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone list the methods that doesn't throw any exception when
1. called on a thread which is already in running state (like setPriority)
2. called on a thread which is dead.
3. called on a thread which is not yet started.
Thanks,
Malar.
 
Uma Viswanathan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer to your first ques
a) yield()
b) getpriority()
c) currentThread()
d) destroy() (but not implemented)
e) interrupted()
f) isInterrupted()
and so on from the API
 
Uma Viswanathan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer to your second ques:
1) getThreadGroup() - This method returns null if this thread has died
 
Malar Ravi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Uma, thanks for your reply. Any inputs for the 3rd question?
Thanks,
Malar.
 
Uma Viswanathan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer for third ques:
isDaemon()
 
Malar Ravi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uma, I think join() can be included in the list for 3rd ques. Correct me if I am wrong.
-Malar.
 
Uma Viswanathan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, bcoz it throws InterruptedException. I think that you want the methods that do not throw any exception. Right?
 
Malar Ravi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Uma,
Yes in question 3, I want the list of methods that do not throw any exception when called on a thread that is not started yet.
The code below doesnt throw any exception when I call join() before thread t is started. So join() can be a valid answer right?

-Malar.
 
Uma Viswanathan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey...i understood that you do not even want to catch the exceptions...
 
Malar Ravi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Uma,
Yes in question 3, I want the list of methods that do not throw any exception when called on a thread that is not started yet.
The code below doesnt throw any exception when I call join() before thread t is started. So join() can be a valid answer right?

-Malar.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the API should answer this ;-)
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic