• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deadlock - Threads  RSS feed

 
Ramakrishnan Ponmudi
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which of the following methods lead to Thread deadlock?
a)stop()
b)sleep()
c)yield()
d)suspend()

answer is either d (or) a & d
which answer is correct?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a whole forum devoted to Threads and Synchronization; I'm moving this thread over there for followup.
 
Yarik Chinskiy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
stop() and suspend() are deprecated.

sleep() does not release the looks so it may cause a dead-lock.
Java doc states that suspend() is deprecated because it is deadlock-prone.
yield() - suggests to ThreadScheduler to let other threads run. Since it does not release a lock, it may cause deadlock.
stop() does not lead to deadlock because it releases all monitores.

This Q. looks more like it belongs in SCJP section.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!