Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to debug a deadlock in the java program?

Posted on 2004-09-01
8
693 Views
Last Modified: 2012-06-21
Hi, everyone:

I have encountered a deadlock in the java program. And I must debug it and correct the deadlock.

The program uses a lot of threads and I have checked the jvm output by clicking "ctrl + \" (dump as below). It shows a deadlock in the program. Could anyone give me some ideas on how to debug the multithreaded program written in java? Is there any tools to help me debug the multithread program?

Thanks.

/----jvm dump----/
...omit something
Found one Java-level deadlock:
=============================
"Thread-0":
  waiting to lock monitor 0x000bee70 (object 0xf1b9e878, a com.lucent.umts.gui.UmtsFrame),
  which is held by "AWT-EventQueue-0"
"AWT-EventQueue-0":
  waiting to lock monitor 0x000bee38 (object 0xf1bfb558, a javax.swing.RepaintManager),
  which is held by "Thread-0"
/----dump end---/
0
Comment
Question by:yangsun
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 11950493
check that you aren't accessing your gui, from a thread other than the event dispatch thread
0
 
LVL 35

Expert Comment

by:girionis
ID: 11950537
Are you using any wait()/notify()? Can you post some sample code? Check the thread that waits. It is possible that you try to notify the thread from the same thread but due to being waiting it can't do anything.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11950542
> Is there any tools to help me debug the multithread program?

Have a look here: http://forum.java.sun.com/thread.jsp?forum=47&thread=517540&tstart=45&trange=15
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 13

Expert Comment

by:Webstorm
ID: 11952207
Hi yangsun,

You can resolve the deadlock : Thread-0 must get all locks in the same order as AWT-EventQueue get them.

0
 
LVL 1

Expert Comment

by:talvio
ID: 11956285
Hi,

hmm, maybe I am wrong here, but without knowing better that looks to me like you might be blocking the AWT thread by using wait(). I think you should not -probably ever- block the AWT thread, because that will always make your GUI unresponsive. Blocking AWT thread is probably caused by calling wait() somewhere in a paint() method or key event listener methods. Those should be easy to scan. If such a call is found, remove it and find another solution for that.

-jT
0
 

Author Comment

by:yangsun
ID: 11963324
Thanks for your helps. I am a newbie to java multithreading. So I have to read some background materials about java multithreading these days.
I will accept one solution after my understanding the basic concept. Thanks.
0
 
LVL 92

Expert Comment

by:objects
ID: 11969015
Here's some background on Swing and threads, basically Swing is single threaded and does not support being accessed by more than one thread:
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
0
 

Author Comment

by:yangsun
ID: 11993385
Thanks. I have fixed the problem.
It is caused by a gui-operation outside the event queue.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 49
SHA2 certs for IIS AND Java? 2 113
hibernate jars 4 45
going to wrong jsp page 2 33
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question