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

Avoiding deadlock

Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

I'm not clear on how to avoid deadlock when using multiple threads.

-- Kaydell
Praveen Balaji
Ranch Hand

Joined: Jun 17, 2001
Posts: 60
This is a generic question. So I'll give search tips rather than try answering that.

You HAVE to understand what threads are, what monitors are, and what wait and notify methods really do. You could start here JavaWorld Article: Synchronizing Threads In Java which is probably one of the few articles that has any mention of a "potential monitor" to an object and implicitly distinguishes between an "object" and a "monitor".

These are the topics to google:

1. Java Thread Synchronization
2. Java Thread Deadlock
3. Java Object Monitor
4. Java Thread Tutorial

If you like to explore further, search for articles on IBM developer works and Artima. Look up JSR 133.

Sun is a nice place to find BEGINNER articles and tutorials on any topics. Just append SUN to your search string.
[ November 24, 2006: Message edited by: praveen balaji ]
Sanjit Kumar
Ranch Hand

Joined: Dec 04, 2006
Posts: 35
there are many algorithms you can use to avoid deadlock.One of them is banker's algorithm and many resources are vaailable on net .
I agree. Here's the link:
subject: Avoiding deadlock
It's not a secret anymore!