Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Thread

 
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.
 
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.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the API should answer this ;-)
 
You get good luck from rubbing the belly of a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic