Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > who can explain this question for me? Thread method

Reply
Thread Tools

who can explain this question for me? Thread method

 
 
Hardy
Guest
Posts: n/a
 
      06-25-2004
there's a certification question like below, the answer is A&E.

which two cannot directly cause a thread to stop executing?
A.calling the yield method
B.calling the wait method on an object
C.calling the notify method on an object
D.calling the notifyAll method on an object
E.calling the start method on another thread object

the api book says: yield public static void yield()Causes the currently
executing thread object to temporarily pause and allow other threads to
execute.
then why A should be selected?

And how about the notify* method? can it DIRECTLY cause a thread to stop
executing?

thanks




 
Reply With Quote
 
 
 
 
Hardy
Guest
Posts: n/a
 
      06-25-2004
I think the yield should not be selected.

the right answer I believe is CDE.

"Hardy" <(E-Mail Removed)> дʼ
news:cbgoa5$23h7$(E-Mail Removed)99.com...
> there's a certification question like below, the answer is A&E.
>
> which two cannot directly cause a thread to stop executing?
> A.calling the yield method
> B.calling the wait method on an object
> C.calling the notify method on an object
> D.calling the notifyAll method on an object
> E.calling the start method on another thread object
>
> the api book says: yield public static void yield()Causes the currently
> executing thread object to temporarily pause and allow other threads to
> execute.
> then why A should be selected?
>
> And how about the notify* method? can it DIRECTLY cause a thread to stop
> executing?
>
> thanks
>
>
>
>




 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      06-25-2004
Hardy wrote:

> there's a certification question like below, the answer is A&E.
>
> which two cannot directly cause a thread to stop executing?
> A.calling the yield method
> B.calling the wait method on an object
> C.calling the notify method on an object
> D.calling the notifyAll method on an object
> E.calling the start method on another thread object


Looks like a typo to me. (C) and (D) do not cause the current thread to stop
executing, they just change the runnable status of any other threads waiting on
the object. (A) and (B) can definitely cause the current thread to stop
executing -- that's what they /mean/ for crissake...

(E) is ambiguous IMO. It doesn't seem to be documented (I can't find a
normative statement anyway) whether Thread.start(), MUST, MUST NOT, or simply
MAY call (some equivalent of) yield(). The docs for Thread.start() say "The
result is that two threads are running concurrently" which, if you squint a
bit, might be taken to mean that the caller does not yield().

So I'd say that the answer is CDE.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code in a class but not in a method -- please explain! Bruce F. Ruby 9 11-07-2010 08:58 PM
how can a child thread notify a parent thread its status? scriptlearner@gmail.com Python 9 07-26-2009 11:50 AM
how can I block a thread until some other thread finished? bearsprite Python 3 12-12-2006 06:08 PM
Please explain SRV.2.3.3.3 Thread Safety clause me.curious@yahoo.com Java 4 01-29-2006 02:38 AM
70-292: can someone please verify / explain the answer to this question Tim Moor MCSE 7 12-18-2005 03:30 AM



Advertisments