who can explain this question for me? Thread method

Discussion in 'Java' started by Hardy, Jun 25, 2004.

  1. Hardy

    Hardy Guest

    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:)
     
    Hardy, Jun 25, 2004
    #1
    1. Advertising

  2. Hardy

    Hardy Guest

    I think the yield should not be selected.

    the right answer I believe is CDE.

    "Hardy" <> дÈëÓʼþ
    news:cbgoa5$23h7$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:)
    >
    >
    >
    >
     
    Hardy, Jun 25, 2004
    #2
    1. Advertising

  3. Hardy

    Chris Uppal Guest

    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.
     
    Chris Uppal, Jun 25, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. renata
    Replies:
    1
    Views:
    791
    Kevin Spencer
    Jun 25, 2003
  2. Replies:
    4
    Views:
    394
    John C. Bollinger
    Jan 29, 2006
  3. bearsprite
    Replies:
    3
    Views:
    600
    Dennis Lee Bieber
    Dec 12, 2006
  4. Bruce F.
    Replies:
    9
    Views:
    82
    Andrew Wagner
    Nov 7, 2010
  5. System Administrator
    Replies:
    1
    Views:
    99
    Richard Cornford
    Mar 11, 2007
Loading...

Share This Page