File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deadlock?

 
Vali GB
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

try to get a deadlock accessing via 2 threads 2 resources in synchronized blocks like:

synchronized(A){
synchronized(B){
}
}
and
synchronized(B){
synchronized(A){
}
}
i try to put the threads on sleep, use system.outs just to make sure my threads are accessing these objects in a convenient way, i know this because i got this output(copied/pasted from one run):
1. u tryin to acquire lock on A
2. u got lock on A, tryin to get lock on B
3. v tryin to acquire lock on B
4. v got lock on B, tryin to get lock on A
5. v got lock on A
6. v thread, freed all locks
7. u got lock on B
... and so on..

so, my question, how's it possible to read the 5th line if the u thread has already the lock on A?

Thanks,
vali
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Threads and Synchronization forum...
[ June 06, 2004: Message edited by: Dirk Schreckmann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic