aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q 28 of examlab practice test 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Q 28 of examlab practice test 3" Watch "Q 28 of examlab practice test 3" New topic
Author

Q 28 of examlab practice test 3

geeta vemula
Ranch Hand

Joined: Jul 18, 2008
Posts: 208


Answer is prints Ex-B and then excetion is thrown.

But my doubt is why there is no effect of the following two statements of main?
doDelay(100);
a.interrupt();
Why is not throwing Interrupted exception?
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
geeta vemula wrote:
But my doubt is why there is no effect of the following two statements of main?
doDelay(100);
a.interrupt();
Why is not throwing Interrupted exception?


doDelay(100); What are you expecting from this line.

a.interrupt(); will cause nothing, as thread reference is pointed by t. If you call t.interrupt, then you could expect its effect.
As no thread is running by reference a, so no effect of a.interrupt.


SCJP 6
Abhishek Bhat
Greenhorn

Joined: Jan 01, 2009
Posts: 25

But Class a itself is a thread...then why wud it not have any effect....

even though the Thread creation method used is the one that is used when the class implements Runnable it wont overshadow the fact that a is a thread and any method in the thread class invoked on t can also be invoked on a ..Please correct me if am wrong...
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
Here a.start() is not called, so thread a is not running, class a' run() is just the target of thread t, actual thread that is running in its own stack is threat referenced by t.
Abhishek Bhat
Greenhorn

Joined: Jan 01, 2009
Posts: 25

Oh Punit..sorry buddy...i dint see that..i just saw that the class extends Thread and put up a dumb show...really sorry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q 28 of examlab practice test 3