File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Are these threads deadlocked? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Are these threads deadlocked?" Watch "Are these threads deadlocked?" New topic
Author

Are these threads deadlocked?

Philip Rissler
Greenhorn

Joined: Sep 13, 2002
Posts: 2
Can someone with more knowledge than I tell me whether the following two threads are in a deadlock? The stack trace doesn't say they are but our application is hanging and having to be restarted.
Thanks.
"BWQ:5335151530645083721" daemon prio=5 tid=0x685c20 nid=0x3a waiting for monitor entry [0xec680000..0xec681a28]
at oracle.jdbc.driver.OracleStatement.describe(OracleStatement.java:5362)
at oracle.jdbc.driver.OracleResultSetMetaData.<init>(OracleResultSetMetaData.java:91)
at oracle.jdbc.driver.ScrollableResultSet.getMetaData(ScrollableResultSet.java:937)
...
"jcp-40" prio=5 tid=0x923d68 nid=0x512 waiting for monitor entry [0xeec80000..0xeec81a28]
at oracle.jdbc.driver.ScrollableResultSet.close(ScrollableResultSet.java:135)
at oracle.jdbc.driver.OracleStatement.scrollStmt_cleanup(OracleStatement.java:6068)
at oracle.jdbc.driver.OracleStatement.internal_close(OracleStatement.java:807)
at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:690)
...

The methods above are defined as:
oracle.jdbc.driver.ScrollableResultSet:
public synchronized ResultSetMetaData getMetaData() ...
public synchronized void close() ...
oracle.jdbc.driver.OracleStatement:
public void describe()
throws SQLException
{
synchronized(connection)
{
synchronized(this)
{....
public void close()
throws SQLException
{
synchronized(connection)
{
synchronized(this)
{...

I'm saying the threads are in a deadlock, but my co-worker says the JVM would tell us if there is a deadlock, so there must not be one. Thanks for your help.
Philip
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

try using the the deadlock detection utility: ( from here)
A deadlock detection utility has been added to the Java HotSpot VM. The utility is invoked by a Ctrl+\ on the command line while an application is running. The utility detects Java-platform-level deadlocks, including locking done from the Java Native Interface (JNI), the Java Virtual Machine Profiler Interface (JVMPI), and Java Virtual Machine Debug Interface (JVMDI).
When invoked, the utility displays a thread dump to standard out and indicates any Java-platform-level deadlocks it detects. Refer to this sample output. If the application is deadlocked because two or more threads are involved in a cylce to acquire monitors, then the list of such threads and monitors involved in the deadlocks are displayed. Note, however, that this will not find deadlocks involving threads waiting on monitors on which no signal will be forthcoming.

Jamie
Philip Rissler
Greenhorn

Joined: Sep 13, 2002
Posts: 2
What are "threads waiting on monitors on which no signal will be forthcoming."?
Another question: If I have a class file with two methods declared as:
private synchronized void open() {
and
public synchronized void close() {
Does this mean that only one thread can be in the combined code of open() and close() at one time or can one thread be in open() while another thread is in close()?
Thanks,
Philip
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are these threads deadlocked?