Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads

 
fraternity lawson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What wight cause the current thread to stop excutings?
A.thread of higher priority become ready. B.method sleep() be called.
C.method stop() be called D.method suspend() be called.
E.method wait() be called

c,b,d,e seem's to be the right answer's.Option A depend's on the platform.Do let me know whether the selected answer's are right or wrong.
 
Ash sav
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me a,b,c,d,e all are correct. Just now I'm done with marcuss green exam and i got almost similar question. So if thread with highest priority is ready then currect thread will stop executing
 
nitin sharma
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ashv,
I go with fraternity on this because if the scheduler is time slice then a thread with higher priority will have no effect,if the scheduler is prepmptive then it will preempt the lower priority thread.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"What wight cause the current thread to stop excutings?"
That "wight" is a very crucial misprint. The question has different answers if that should be "will" versus if it is "might" - which is it supposed to be?
Bill
 
Tracy Qi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen similar questions all around. My questions is:
How about the thread create a intreputed exception during the execution. Will this stop the thread? I think it will, But seems nobody agree with me. Can somebody tell me why?

Thanks.

 
John M. Gabriele
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
note that there won't be any questions on the exam
regarding deprecated methods. Thread's stop() is
deprecated.
 
Simon Baker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suspend() is also deprecated. The question was probably "might" in which case it looks as though all options are valid. As far as the Java code is concerned you cannot predict whether a higher priority thread will cause the current thread to move to the ready-to-run state. This behaviour is dependant on the thread scheduler, which in turn depends on the underlying platform. Java is platform independent and so the language itself does not enforce how the scheduler should operate.
 
Ravindra Mohan
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
Let me sum it up , on the discussion in this thread. This question is from marcus green's test. The correct in the test is
(A), (B) and (E). The reason as pointed out is on account of the fact that suspend() , stop() methods are deprecated in Java 2.
In the SCJP context we must be very careful on the
wording of the question. The question here cleverly asks that
What wight cause the current thread to stop excutings?
The catch is "might" and NOT "will".
I guess this will end the discussion regarding this issue.
Cheers,
Ravindra Mohan

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic