Solved

How to debug a deadlock in the java program?

Posted on 2004-09-01
8
692 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Server Faces parameter pass? 6 50
javap not working 8 45
SHA2 certs for IIS AND Java? 2 90
Which non-HTML GUI front end to use with Java? 3 22
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

773 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