who can explain this question for me? Thread method

H

Hardy

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:)
 
C

Chris Uppal

Hardy said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top