Skip to content

Instantly share code, notes, and snippets.

@coderplay
Last active Dec 12, 2015
Embed
What would you like to do?
class Lock {}
class Danger {
static {
System.out.println("clinit begin...");
try {Thread.sleep(2000);} catch (Exception e) {}
synchronized (Lock.class) { System.out.println("clinit done!");}
}
}
public class Hang {
public static void main(String[] args) {
new Thread() {
public void run() {
synchronized (Lock.class) {
System.out.println("new thread start!");
try {Thread.sleep(1000);} catch (Exception e) {}
new Danger();
}
System.out.println("new thread end!");
}
}.start();
try {Thread.sleep(500);} catch (Exception e) {}
System.out.println(new Danger());
System.out.println("DONE!");
}
}
$ pstack `pgrep -f Demo2`
Thread 24 (Thread 0x40d7d940 (LWP 10103)):
#0 0x0000003b8ac0ae00 in pthread_cond_timedwait@@GLIBC_2.3.2 ()
#1 0x00007fa628a585a6 in os::PlatformEvent::park ()
#2 0x00007fa628b28009 in ObjectMonitor::EnterI ()
#3 0x00007fa628b28722 in ObjectMonitor::enter ()
#4 0x00007fa628b2655b in ObjectSynchronizer::slow_enter ()
#5 0x00007fa628b26454 in ObjectSynchronizer::fast_enter ()
#6 0x00007fa628836d3a in InterpreterRuntime::monitorenter ()
#7 0x00007fa624dd9c00 in ?? ()
#8 0x0000000040d7c7b0 in ?? ()
#9 0x00007fa624dd9bcc in ?? ()
#10 0x0000000000000003 in ?? ()
#11 0x0000000681a66c78 in ?? ()
#12 0x0000000040d7c760 in ?? ()
#13 0x0000000681a67128 in ?? ()
#14 0x0000000040d7c7c8 in ?? ()
#15 0x0000000681a67478 in ?? ()
#16 0x0000000000000000 in ?? ()
Thread 23 (Thread 0x41386940 (LWP 10104)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 22 (Thread 0x4020a940 (LWP 10105)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 21 (Thread 0x40724940 (LWP 10106)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 20 (Thread 0x4036c940 (LWP 10107)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 19 (Thread 0x41b58940 (LWP 10108)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 18 (Thread 0x41c59940 (LWP 10109)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 17 (Thread 0x41744940 (LWP 10110)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 16 (Thread 0x41d5a940 (LWP 10111)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 15 (Thread 0x41845940 (LWP 10112)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 14 (Thread 0x41e5b940 (LWP 10113)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 13 (Thread 0x40f2b940 (LWP 10114)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 12 (Thread 0x4052c940 (LWP 10115)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 11 (Thread 0x411cb940 (LWP 10116)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6287cb005 in GCTaskManager::get_task ()
#5 0x00007fa6287cc313 in GCTaskThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 10 (Thread 0x40825940 (LWP 10117)):
#0 0x0000003b8ac0ae00 in pthread_cond_timedwait@@GLIBC_2.3.2 ()
#1 0x00007fa628a585a6 in os::PlatformEvent::park ()
#2 0x00007fa628a2e85b in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa628bacef3 in VMThread::loop ()
#5 0x00007fa628bacaee in VMThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 9 (Thread 0x41f6f940 (LWP 10118)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628b2963a in ObjectMonitor::wait ()
#3 0x00007fa628b26883 in ObjectSynchronizer::wait ()
#4 0x00007fa6288aa0ce in JVM_MonitorWait ()
#5 0x00007fa624dcdcc8 in ?? ()
#6 0x00007fa623846ac0 in ?? ()
#7 0x00007fa623846e98 in ?? ()
#8 0x00007fa623846000 in ?? ()
#9 0x0000000041f6ebf8 in ?? ()
#10 0x0000000681808828 in ?? ()
#11 0x0000000041f6ec68 in ?? ()
#12 0x00000006818a1598 in ?? ()
#13 0x0000000000000000 in ?? ()
Thread 8 (Thread 0x41487940 (LWP 10119)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628b2963a in ObjectMonitor::wait ()
#3 0x00007fa628b26883 in ObjectSynchronizer::wait ()
#4 0x00007fa6288aa0ce in JVM_MonitorWait ()
#5 0x00007fa624dcdcc8 in ?? ()
#6 0x00007fa623848bd0 in ?? ()
#7 0x00007fa623848fa8 in ?? ()
#8 0x00007fa623848800 in ?? ()
#9 0x00007fa623848fe8 in ?? ()
#10 0x0000000041486b10 in ?? ()
#11 0x0000000000000000 in ?? ()
Thread 7 (Thread 0x42070940 (LWP 10120)):
#0 0x0000003b8ac0c9b1 in sem_wait () from /lib64/libpthread.so.0
#1 0x00007fa628a591e5 in check_pending_signals ()
#2 0x00007fa628a51a8c in signal_thread_entry ()
#3 0x00007fa628b5b8c1 in JavaThread::run ()
#4 0x00007fa628a58e1f in java_start ()
#5 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#6 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 6 (Thread 0x40a21940 (LWP 10121)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2ed8d in Monitor::wait ()
#4 0x00007fa62870f07f in CompileQueue::get ()
#5 0x00007fa628710c11 in CompileBroker::compiler_thread_loop ()
#6 0x00007fa628b62159 in compiler_thread_entry ()
#7 0x00007fa628b5b8c1 in JavaThread::run ()
#8 0x00007fa628a58e1f in java_start ()
#9 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#10 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 5 (Thread 0x41588940 (LWP 10122)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2ed8d in Monitor::wait ()
#4 0x00007fa62870f07f in CompileQueue::get ()
#5 0x00007fa628710c11 in CompileBroker::compiler_thread_loop ()
#6 0x00007fa628b62159 in compiler_thread_entry ()
#7 0x00007fa628b5b8c1 in JavaThread::run ()
#8 0x00007fa628a58e1f in java_start ()
#9 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#10 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 4 (Thread 0x41089940 (LWP 10123)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628a2e725 in Monitor::IWait ()
#3 0x00007fa628a2eeee in Monitor::wait ()
#4 0x00007fa6289d5a82 in LowMemoryDetector::low_memory_detector_thread_entry
#5 0x00007fa628b5b8c1 in JavaThread::run ()
#6 0x00007fa628a58e1f in java_start ()
#7 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#8 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 3 (Thread 0x41946940 (LWP 10124)):
#0 0x0000003b8ac0ae00 in pthread_cond_timedwait@@GLIBC_2.3.2 ()
#1 0x00007fa628a585a6 in os::PlatformEvent::park ()
#2 0x00007fa628b5a93b in WatcherThread::run ()
#3 0x00007fa628a58e1f in java_start ()
#4 0x0000003b8ac064a7 in start_thread () from /lib64/libpthread.so.0
#5 0x0000003b8a4d3c2d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x41a47940 (LWP 10125)):
#0 0x0000003b8ac0ab99 in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007fa628a5844e in os::PlatformEvent::park ()
#2 0x00007fa628b2963a in ObjectMonitor::wait ()
#3 0x00007fa628b26920 in ObjectSynchronizer::waitUninterruptibly ()
#4 0x00007fa62880e29b in instanceKlass::initialize_impl ()
#5 0x00007fa62880d8da in instanceKlass::initialize ()
#6 0x00007fa6288341dc in InterpreterRuntime::_new ()
#7 0x00007fa624dd92cc in ?? ()
#8 0x00000000000003e8 in ?? ()
#9 0x00007fa624dd9298 in ?? ()
#10 0x0000000000000001 in ?? ()
#11 0x0000000681a66c78 in ?? ()
#12 0x0000000041a46b50 in ?? ()
#13 0x0000000681a66060 in ?? ()
#14 0x0000000041a46bc8 in ?? ()
#15 0x0000000681a664b8 in ?? ()
#16 0x0000000000000000 in ?? ()
Thread 1 (Thread 0x7fa628f176e0 (LWP 10102)):
#0 0x0000003b8ac077e5 in pthread_join () from /lib64/libpthread.so.0
#1 0x00000000400058fc in ContinueInNewThread ()
#2 0x0000000040001ee9 in main ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment