• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

threads?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What might cause the current thread to stop executing?
A. An InterruptedException is thrown
B. The thread executes a sleep() call
C. The thread constructs a new Thread
D. A thread of higher priority becomes ready (runnable)
E. The thread executes a read() call on an InputStream
ans:B,D,E
can anybody explain why A is wrong & E is correct

2:Which statements are true about threads?
A. Threads created from the same class all finish together
B. A thread can be created only by subclassing Java.Lang.Thread.
C. Invoking the suspend() stops a thread so that it cannot be restarted
D. The Java Interpreter's natural exit occurs when no non daemon
threads remain alive
E. Uncoordinated changes to shared data by multiple threads may result
in the data being read, or left, in an inconsistent state.
MY ANS:CDE.
ans given are E
why ans C is incorrect?
pls help
thanx
sherinn
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sherin,
In your answer to the 2 question U said C,D,E are the right choices.
C. Invoking the suspend() stops a thread so that it cannot be restarted.
False - bcoz resume() will restart it again.
Aruna
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In regards to the second question,shouldn't the right answer be D and E. Please could somebody explain as to why D is not correct?
Thanks,
Ira
------------------
 
sheri
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ira
the correct ans are ,E
sherin
 
sheri
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi again ira

the ans are d,e
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With regard to question 2
C. Invoking the suspend() stops a thread so that it cannot be restarted
and Why C is not correct, this is what the Java 2 Certification by 'Jamie Jaworski' says, and I am curious if it is correct or not.
'Prior to JDK 1.2, it was possible for one thread to stop or suspend the execution of another thread(or itself). The stop(), suspend(), and resume() methods have been identified as problematic and are deprecated in JDK 1.2'
According to that statement, C is not correct because the methods are no longer supported?
Can anybody set us straight on this, it would concern me if my study guide had errors as bad as this.
Thanks
Guy
 
Guy Van Iseghem
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With question 1
I see A as incorrect because the question asks what could CAUSE a thread to stop executing, the InterruptedException is thrown as a result of a thread being interrupted, the exception did not cause the thread to stop executing, it would be a statement like interrupt().
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For question 1)
(A) is wrong because thread is already in the wait mode when this exception occurs.
(E) is right beacuse read() puts the thread in a blocked state.
For question 2)
(C) is wrong because because another thread can start the suspended thread.
(D) seems to be right for me.
Please do give comments on these.

Sagar
 
reply
    Bookmark Topic Watch Topic
  • New Topic