File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes deadlock? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "deadlock?" Watch "deadlock?" New topic


Vali GB

Joined: Jun 06, 2004
Posts: 7
Hi all,

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

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?

Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Threads and Synchronization forum...
[ June 06, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: deadlock?
jQuery in Action, 3rd edition