Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Possible to show java.util.concurrent locks in Debug view?
Possible to show java.util.concurrent locks in Debug view? [message #649046] Mon, 17 January 2011 12:27 Go to next message
Walter Laan is currently offline Walter LaanFriend
Messages: 4
Registered: July 2009
Junior Member
Hi,
the Java debug view can show the locks a thread has or is waiting for but this only works for locks set with synchronized keyword.

Am I missing an option to show locks set with for example with a java.util.concurrent.ReentrantLock? If I do a thread dump in VisualVM that information is available.
I could not find an existing feature request in the bug database so I could make one it it's not a available.

import java.util.concurrent.locks.ReentrantLock;

public class TestLockDebug {
    public static void main(String[] args) {
        Object lock1 = new Object();
        ReentrantLock lock2 = new ReentrantLock();
        try {
            lock2.lock();
            synchronized (lock1) {
                try {
                    Thread.sleep(100000);
                }
                catch (InterruptedException ignore) {
                }
            }
        }
        finally {
            lock2.unlock();
        }
    }
}

Using JDK 6u23:

Eclipse Helios Release Build id: 20100617-1415:
Thread [main] (Suspended)	
	owns: Object  (id=15)	
	Thread.sleep(long) line: not available [native method]	
	TestLockDebug.main(String[]) line: 13	

VisualVM 1.3.1 thread dump:
"main" prio=6 tid=0x003b8400 nid=0x1120 waiting on condition [0x0090f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at TestLockDebug.main(TestLockDebug.java:13)
	- locked <0x02e60c30> (a java.lang.Object)

   Locked ownable synchronizers:
	- <0x02e6c600> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)


Re: Possible to show java.util.concurrent locks in Debug view? [message #649189 is a reply to message #649046] Tue, 18 January 2011 04:59 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 545
Registered: July 2009
Senior Member
On 1/17/2011 5:57 PM, Walter Laan wrote:
> Hi,
> the Java debug view can show the locks a thread has or is waiting for
> but this only works for locks set with synchronized keyword.
>
> Am I missing an option to show locks set with for example with a
> java.util.concurrent.ReentrantLock? If I do a thread dump in VisualVM
> that information is available.
> I could not find an existing feature request in the bug database so I
> could make one it it's not a available.
Please file an enhancement request.
Re: Possible to show java.util.concurrent locks in Debug view? [message #649273 is a reply to message #649189] Tue, 18 January 2011 14:34 Go to previous message
Walter Laan is currently offline Walter LaanFriend
Messages: 4
Registered: July 2009
Junior Member
I've created https://bugs.eclipse.org/bugs/show_bug.cgi?id=334647
Previous Topic:ASTRewrite.replace() and ASTRewrite.createGroupNode()
Next Topic:Error with decompiler editor
Goto Forum:
  


Current Time: Mon Dec 29 15:58:38 GMT 2014

Powered by FUDForum. Page generated in 0.03858 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software