• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Suspending a thread question

 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is from JavaCertificate.com:


Which mechanisms suspend a Thread execution? [Check all correct answers]


1. sleep()
2. pause()
3. init()
4. wait()
5. synchronized code
Feedback:
Answer 1, 4 and 5 are correct.
The sleep() and the wait() method will suspend the current thread from execution. The synchronized code will put a lock on objects, this suspends execution.
The sleep() and wait() method guarantees the thread of suspension, where the synchronized may suspend the thread, only if the thread does not obtain the object lock.
Suspending a thread is a mechanism that allows any thread to make another thread unready for an unlimited amount of time, this can causes dead-locks.


Is it a valid explanation for the synchronized mechanism with regards to suspension?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I thought suspension of a thread means suspending the current thread under execution while allowing other thread/threads to execute or have the control during the suspension time and after the sleep or suspension period is over, the first thread may or may not gain control.But your definition of "suspension of a thread" states that suspension is suspending other threads from taking control, which is different from what I thought.
Correct me if I am wrong.
GuruG.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gurug,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic