This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread" Watch "Thread" New topic
Author

Thread

Malar Ravi
Ranch Hand

Joined: Oct 15, 2001
Posts: 51
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

Joined: Jun 14, 2001
Posts: 126
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

Joined: Jun 14, 2001
Posts: 126
Answer to your second ques:
1) getThreadGroup() - This method returns null if this thread has died
Malar Ravi
Ranch Hand

Joined: Oct 15, 2001
Posts: 51
Hi Uma, thanks for your reply. Any inputs for the 3rd question?
Thanks,
Malar.
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Answer for third ques:
isDaemon()
Malar Ravi
Ranch Hand

Joined: Oct 15, 2001
Posts: 51
Uma, I think join() can be included in the list for 3rd ques. Correct me if I am wrong.
-Malar.
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
No, bcoz it throws InterruptedException. I think that you want the methods that do not throw any exception. Right?
Malar Ravi
Ranch Hand

Joined: Oct 15, 2001
Posts: 51
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

Joined: Jun 14, 2001
Posts: 126
Hey...i understood that you do not even want to catch the exceptions...
Malar Ravi
Ranch Hand

Joined: Oct 15, 2001
Posts: 51
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

Joined: Jul 03, 2001
Posts: 2120
I think the API should answer this ;-)


SCJP2. Please Indent your code using UBB Code
 
 
subject: Thread