duke@435: /* xdono@905: * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: class OopClosure; duke@435: class ThreadDumpResult; duke@435: class ThreadStackTrace; duke@435: class ThreadSnapshot; duke@435: class StackFrameInfo; duke@435: class ThreadConcurrentLocks; duke@435: class DeadlockCycle; duke@435: duke@435: // VM monitoring and management support for the thread and duke@435: // synchronization subsystem duke@435: // duke@435: // Thread contention monitoring is disabled by default. duke@435: // When enabled, the VM will begin measuring the accumulated duke@435: // elapsed time a thread blocked on synchronization. duke@435: // duke@435: class ThreadService : public AllStatic { duke@435: private: duke@435: // These counters could be moved to Threads class duke@435: static PerfCounter* _total_threads_count; duke@435: static PerfVariable* _live_threads_count; duke@435: static PerfVariable* _peak_threads_count; duke@435: static PerfVariable* _daemon_threads_count; duke@435: duke@435: // These 2 counters are atomically incremented once the thread is exiting. duke@435: // They will be atomically decremented when ThreadService::remove_thread is called. duke@435: static volatile int _exiting_threads_count; duke@435: static volatile int _exiting_daemon_threads_count; duke@435: duke@435: static bool _thread_monitoring_contention_enabled; duke@435: static bool _thread_cpu_time_enabled; duke@435: duke@435: // Need to keep the list of thread dump result that duke@435: // keep references to methodOop since thread dump can be duke@435: // requested by multiple threads concurrently. duke@435: static ThreadDumpResult* _threaddump_list; duke@435: duke@435: public: duke@435: static void init(); duke@435: static void add_thread(JavaThread* thread, bool daemon); duke@435: static void remove_thread(JavaThread* thread, bool daemon); duke@435: static void current_thread_exiting(JavaThread* jt); duke@435: duke@435: static bool set_thread_monitoring_contention(bool flag); duke@435: static bool is_thread_monitoring_contention() { return _thread_monitoring_contention_enabled; } duke@435: duke@435: static bool set_thread_cpu_time_enabled(bool flag); duke@435: static bool is_thread_cpu_time_enabled() { return _thread_cpu_time_enabled; } duke@435: duke@435: static jlong get_total_thread_count() { return _total_threads_count->get_value(); } duke@435: static jlong get_peak_thread_count() { return _peak_threads_count->get_value(); } duke@435: static jlong get_live_thread_count() { return _live_threads_count->get_value() - _exiting_threads_count; } duke@435: static jlong get_daemon_thread_count() { return _daemon_threads_count->get_value() - _exiting_daemon_threads_count; } duke@435: duke@435: static int exiting_threads_count() { return _exiting_threads_count; } duke@435: static int exiting_daemon_threads_count() { return _exiting_daemon_threads_count; } duke@435: duke@435: // Support for thread dump duke@435: static void add_thread_dump(ThreadDumpResult* dump); duke@435: static void remove_thread_dump(ThreadDumpResult* dump); duke@435: duke@435: static Handle get_current_contended_monitor(JavaThread* thread); duke@435: duke@435: // This function is called by JVM_DumpThreads. duke@435: static Handle dump_stack_traces(GrowableArray* threads, duke@435: int num_threads, TRAPS); duke@435: duke@435: static void reset_peak_thread_count(); duke@435: static void reset_contention_count_stat(JavaThread* thread); duke@435: static void reset_contention_time_stat(JavaThread* thread); duke@435: duke@435: static DeadlockCycle* find_deadlocks_at_safepoint(bool object_monitors_only); duke@435: duke@435: // GC support duke@435: static void oops_do(OopClosure* f); duke@435: }; duke@435: duke@435: // Per-thread Statistics for synchronization duke@435: class ThreadStatistics : public CHeapObj { duke@435: private: duke@435: // The following contention statistics are only updated by duke@435: // the thread owning these statistics when contention occurs. duke@435: duke@435: jlong _contended_enter_count; duke@435: elapsedTimer _contended_enter_timer; duke@435: jlong _monitor_wait_count; duke@435: elapsedTimer _monitor_wait_timer; duke@435: jlong _sleep_count; duke@435: elapsedTimer _sleep_timer; duke@435: duke@435: duke@435: // These two reset flags are set to true when another thread duke@435: // requests to reset the statistics. The actual statistics duke@435: // are reset when the thread contention occurs and attempts duke@435: // to update the statistics. duke@435: bool _count_pending_reset; duke@435: bool _timer_pending_reset; duke@435: duke@435: // Keep accurate times for potentially recursive class operations duke@435: int _class_init_recursion_count; duke@435: int _class_verify_recursion_count; duke@435: int _class_link_recursion_count; duke@435: duke@435: // utility functions duke@435: void check_and_reset_count() { duke@435: if (!_count_pending_reset) return; duke@435: _contended_enter_count = 0; duke@435: _monitor_wait_count = 0; duke@435: _sleep_count = 0; duke@435: _count_pending_reset = 0; duke@435: } duke@435: void check_and_reset_timer() { duke@435: if (!_timer_pending_reset) return; duke@435: _contended_enter_timer.reset(); duke@435: _monitor_wait_timer.reset(); duke@435: _sleep_timer.reset(); duke@435: _timer_pending_reset = 0; duke@435: } duke@435: duke@435: public: duke@435: ThreadStatistics(); duke@435: duke@435: jlong contended_enter_count() { return (_count_pending_reset ? 0 : _contended_enter_count); } duke@435: jlong contended_enter_ticks() { return (_timer_pending_reset ? 0 : _contended_enter_timer.active_ticks()); } duke@435: jlong monitor_wait_count() { return (_count_pending_reset ? 0 : _monitor_wait_count); } duke@435: jlong monitor_wait_ticks() { return (_timer_pending_reset ? 0 : _monitor_wait_timer.active_ticks()); } duke@435: jlong sleep_count() { return (_count_pending_reset ? 0 : _sleep_count); } duke@435: jlong sleep_ticks() { return (_timer_pending_reset ? 0 : _sleep_timer.active_ticks()); } duke@435: duke@435: void monitor_wait() { check_and_reset_count(); _monitor_wait_count++; } duke@435: void monitor_wait_begin() { check_and_reset_timer(); _monitor_wait_timer.start(); } duke@435: void monitor_wait_end() { _monitor_wait_timer.stop(); check_and_reset_timer(); } duke@435: duke@435: void thread_sleep() { check_and_reset_count(); _sleep_count++; } duke@435: void thread_sleep_begin() { check_and_reset_timer(); _sleep_timer.start(); } duke@435: void thread_sleep_end() { _sleep_timer.stop(); check_and_reset_timer(); } duke@435: duke@435: void contended_enter() { check_and_reset_count(); _contended_enter_count++; } duke@435: void contended_enter_begin() { check_and_reset_timer(); _contended_enter_timer.start(); } duke@435: void contended_enter_end() { _contended_enter_timer.stop(); check_and_reset_timer(); } duke@435: duke@435: void reset_count_stat() { _count_pending_reset = true; } duke@435: void reset_time_stat() { _timer_pending_reset = true; } duke@435: duke@435: int* class_init_recursion_count_addr() { return &_class_init_recursion_count; } duke@435: int* class_verify_recursion_count_addr() { return &_class_verify_recursion_count; } duke@435: int* class_link_recursion_count_addr() { return &_class_link_recursion_count; } duke@435: }; duke@435: duke@435: // Thread snapshot to represent the thread state and statistics duke@435: class ThreadSnapshot : public CHeapObj { duke@435: private: duke@435: JavaThread* _thread; duke@435: oop _threadObj; duke@435: java_lang_Thread::ThreadStatus _thread_status; duke@435: duke@435: bool _is_ext_suspended; duke@435: bool _is_in_native; duke@435: duke@435: jlong _contended_enter_ticks; duke@435: jlong _contended_enter_count; duke@435: jlong _monitor_wait_ticks; duke@435: jlong _monitor_wait_count; duke@435: jlong _sleep_ticks; duke@435: jlong _sleep_count; duke@435: oop _blocker_object; duke@435: oop _blocker_object_owner; duke@435: duke@435: ThreadStackTrace* _stack_trace; duke@435: ThreadConcurrentLocks* _concurrent_locks; duke@435: ThreadSnapshot* _next; duke@435: duke@435: public: duke@435: // Dummy snapshot duke@435: ThreadSnapshot() : _thread(NULL), _threadObj(NULL), _stack_trace(NULL), _concurrent_locks(NULL), _next(NULL), duke@435: _blocker_object(NULL), _blocker_object_owner(NULL) {}; duke@435: ThreadSnapshot(JavaThread* thread); duke@435: ~ThreadSnapshot(); duke@435: duke@435: java_lang_Thread::ThreadStatus thread_status() { return _thread_status; } duke@435: duke@435: oop threadObj() const { return _threadObj; } duke@435: duke@435: void set_next(ThreadSnapshot* n) { _next = n; } duke@435: duke@435: bool is_ext_suspended() { return _is_ext_suspended; } duke@435: bool is_in_native() { return _is_in_native; } duke@435: duke@435: jlong contended_enter_count() { return _contended_enter_count; } duke@435: jlong contended_enter_ticks() { return _contended_enter_ticks; } duke@435: jlong monitor_wait_count() { return _monitor_wait_count; } duke@435: jlong monitor_wait_ticks() { return _monitor_wait_ticks; } duke@435: jlong sleep_count() { return _sleep_count; } duke@435: jlong sleep_ticks() { return _sleep_ticks; } duke@435: duke@435: duke@435: oop blocker_object() { return _blocker_object; } duke@435: oop blocker_object_owner() { return _blocker_object_owner; } duke@435: duke@435: ThreadSnapshot* next() const { return _next; } duke@435: ThreadStackTrace* get_stack_trace() { return _stack_trace; } duke@435: ThreadConcurrentLocks* get_concurrent_locks() { return _concurrent_locks; } duke@435: duke@435: void dump_stack_at_safepoint(int max_depth, bool with_locked_monitors); duke@435: void set_concurrent_locks(ThreadConcurrentLocks* l) { _concurrent_locks = l; } duke@435: void oops_do(OopClosure* f); duke@435: }; duke@435: duke@435: class ThreadStackTrace : public CHeapObj { duke@435: private: duke@435: JavaThread* _thread; duke@435: int _depth; // number of stack frames added duke@435: bool _with_locked_monitors; duke@435: GrowableArray* _frames; duke@435: GrowableArray* _jni_locked_monitors; duke@435: duke@435: public: duke@435: duke@435: ThreadStackTrace(JavaThread* thread, bool with_locked_monitors); duke@435: ~ThreadStackTrace(); duke@435: mchung@831: JavaThread* thread() { return _thread; } duke@435: StackFrameInfo* stack_frame_at(int i) { return _frames->at(i); } duke@435: int get_stack_depth() { return _depth; } duke@435: duke@435: void add_stack_frame(javaVFrame* jvf); duke@435: void dump_stack_at_safepoint(int max_depth); duke@435: Handle allocate_fill_stack_trace_element_array(TRAPS); duke@435: void oops_do(OopClosure* f); duke@435: GrowableArray* jni_locked_monitors() { return _jni_locked_monitors; } duke@435: int num_jni_locked_monitors() { return (_jni_locked_monitors != NULL ? _jni_locked_monitors->length() : 0); } duke@435: duke@435: bool is_owned_monitor_on_stack(oop object); duke@435: void add_jni_locked_monitor(oop object) { _jni_locked_monitors->append(object); } duke@435: }; duke@435: duke@435: // StackFrameInfo for keeping methodOop and bci during duke@435: // stack walking for later construction of StackTraceElement[] duke@435: // Java instances duke@435: class StackFrameInfo : public CHeapObj { duke@435: private: duke@435: methodOop _method; duke@435: int _bci; duke@435: GrowableArray* _locked_monitors; // list of object monitors locked by this frame duke@435: duke@435: public: duke@435: duke@435: StackFrameInfo(javaVFrame* jvf, bool with_locked_monitors); duke@435: ~StackFrameInfo() { duke@435: if (_locked_monitors != NULL) { duke@435: delete _locked_monitors; duke@435: } duke@435: }; duke@435: methodOop method() const { return _method; } duke@435: int bci() const { return _bci; } duke@435: void oops_do(OopClosure* f); duke@435: duke@435: int num_locked_monitors() { return (_locked_monitors != NULL ? _locked_monitors->length() : 0); } duke@435: GrowableArray* locked_monitors() { return _locked_monitors; } duke@435: duke@435: void print_on(outputStream* st) const; duke@435: }; duke@435: duke@435: class ThreadConcurrentLocks : public CHeapObj { duke@435: private: duke@435: GrowableArray* _owned_locks; duke@435: ThreadConcurrentLocks* _next; duke@435: JavaThread* _thread; duke@435: public: duke@435: ThreadConcurrentLocks(JavaThread* thread); duke@435: ~ThreadConcurrentLocks(); duke@435: duke@435: void add_lock(instanceOop o); duke@435: void set_next(ThreadConcurrentLocks* n) { _next = n; } duke@435: ThreadConcurrentLocks* next() { return _next; } duke@435: JavaThread* java_thread() { return _thread; } duke@435: GrowableArray* owned_locks() { return _owned_locks; } duke@435: void oops_do(OopClosure* f); duke@435: }; duke@435: duke@435: class ConcurrentLocksDump : public StackObj { duke@435: private: duke@435: ThreadConcurrentLocks* _map; duke@435: ThreadConcurrentLocks* _last; // Last ThreadConcurrentLocks in the map duke@435: bool _retain_map_on_free; duke@435: duke@435: void build_map(GrowableArray* aos_objects); duke@435: void add_lock(JavaThread* thread, instanceOop o); duke@435: duke@435: public: duke@435: ConcurrentLocksDump(bool retain_map_on_free) : _map(NULL), _last(NULL), _retain_map_on_free(retain_map_on_free) {}; duke@435: ConcurrentLocksDump() : _map(NULL), _last(NULL), _retain_map_on_free(false) {}; duke@435: ~ConcurrentLocksDump(); duke@435: duke@435: void dump_at_safepoint(); duke@435: ThreadConcurrentLocks* thread_concurrent_locks(JavaThread* thread); duke@435: void print_locks_on(JavaThread* t, outputStream* st); duke@435: }; duke@435: duke@435: class ThreadDumpResult : public StackObj { duke@435: private: duke@435: int _num_threads; duke@435: int _num_snapshots; duke@435: ThreadSnapshot* _snapshots; duke@435: ThreadSnapshot* _last; duke@435: ThreadDumpResult* _next; duke@435: public: duke@435: ThreadDumpResult(); duke@435: ThreadDumpResult(int num_threads); duke@435: ~ThreadDumpResult(); duke@435: duke@435: void add_thread_snapshot(ThreadSnapshot* ts); duke@435: void set_next(ThreadDumpResult* next) { _next = next; } duke@435: ThreadDumpResult* next() { return _next; } duke@435: int num_threads() { return _num_threads; } duke@435: int num_snapshots() { return _num_snapshots; } duke@435: ThreadSnapshot* snapshots() { return _snapshots; } duke@435: void oops_do(OopClosure* f); duke@435: }; duke@435: duke@435: class DeadlockCycle : public CHeapObj { duke@435: private: duke@435: bool _is_deadlock; duke@435: GrowableArray* _threads; duke@435: DeadlockCycle* _next; duke@435: public: duke@435: DeadlockCycle(); duke@435: ~DeadlockCycle(); duke@435: duke@435: DeadlockCycle* next() { return _next; } duke@435: void set_next(DeadlockCycle* d) { _next = d; } duke@435: void add_thread(JavaThread* t) { _threads->append(t); } duke@435: void reset() { _is_deadlock = false; _threads->clear(); } duke@435: void set_deadlock(bool value) { _is_deadlock = value; } duke@435: bool is_deadlock() { return _is_deadlock; } duke@435: int num_threads() { return _threads->length(); } duke@435: GrowableArray* threads() { return _threads; } duke@435: void print_on(outputStream* st) const; duke@435: }; duke@435: duke@435: // Utility class to get list of java threads. duke@435: class ThreadsListEnumerator : public StackObj { duke@435: private: duke@435: GrowableArray* _threads_array; duke@435: public: duke@435: ThreadsListEnumerator(Thread* cur_thread, duke@435: bool include_jvmti_agent_threads = false, duke@435: bool include_jni_attaching_threads = true); duke@435: int num_threads() { return _threads_array->length(); } duke@435: instanceHandle get_threadObj(int index) { return _threads_array->at(index); } duke@435: }; duke@435: duke@435: duke@435: // abstract utility class to set new thread states, and restore previous after the block exits duke@435: class JavaThreadStatusChanger : public StackObj { duke@435: private: duke@435: java_lang_Thread::ThreadStatus _old_state; duke@435: JavaThread* _java_thread; duke@435: bool _is_alive; duke@435: duke@435: void save_old_state(JavaThread* java_thread) { duke@435: _java_thread = java_thread; duke@435: _is_alive = is_alive(java_thread); duke@435: if (is_alive()) { duke@435: _old_state = java_lang_Thread::get_thread_status(_java_thread->threadObj()); duke@435: } duke@435: } duke@435: duke@435: public: duke@435: static void set_thread_status(JavaThread* java_thread, duke@435: java_lang_Thread::ThreadStatus state) { duke@435: java_lang_Thread::set_thread_status(java_thread->threadObj(), state); duke@435: } duke@435: duke@435: void set_thread_status(java_lang_Thread::ThreadStatus state) { duke@435: if (is_alive()) { duke@435: set_thread_status(_java_thread, state); duke@435: } duke@435: } duke@435: duke@435: JavaThreadStatusChanger(JavaThread* java_thread, duke@435: java_lang_Thread::ThreadStatus state) { duke@435: save_old_state(java_thread); duke@435: set_thread_status(state); duke@435: } duke@435: duke@435: JavaThreadStatusChanger(JavaThread* java_thread) { duke@435: save_old_state(java_thread); duke@435: } duke@435: duke@435: ~JavaThreadStatusChanger() { duke@435: set_thread_status(_old_state); duke@435: } duke@435: duke@435: static bool is_alive(JavaThread* java_thread) { duke@435: return java_thread != NULL && java_thread->threadObj() != NULL; duke@435: } duke@435: duke@435: bool is_alive() { duke@435: return _is_alive; duke@435: } duke@435: }; duke@435: duke@435: // Change status to waiting on an object (timed or indefinite) duke@435: class JavaThreadInObjectWaitState : public JavaThreadStatusChanger { duke@435: private: duke@435: ThreadStatistics* _stat; duke@435: bool _active; duke@435: duke@435: public: duke@435: JavaThreadInObjectWaitState(JavaThread *java_thread, bool timed) : duke@435: JavaThreadStatusChanger(java_thread, duke@435: timed ? java_lang_Thread::IN_OBJECT_WAIT_TIMED : java_lang_Thread::IN_OBJECT_WAIT) { duke@435: if (is_alive()) { duke@435: _stat = java_thread->get_thread_stat(); duke@435: _active = ThreadService::is_thread_monitoring_contention(); duke@435: _stat->monitor_wait(); duke@435: if (_active) { duke@435: _stat->monitor_wait_begin(); duke@435: } duke@435: } else { duke@435: _active = false; duke@435: } duke@435: } duke@435: duke@435: ~JavaThreadInObjectWaitState() { duke@435: if (_active) { duke@435: _stat->monitor_wait_end(); duke@435: } duke@435: } duke@435: }; duke@435: duke@435: // Change status to parked (timed or indefinite) duke@435: class JavaThreadParkedState : public JavaThreadStatusChanger { duke@435: private: duke@435: ThreadStatistics* _stat; duke@435: bool _active; duke@435: duke@435: public: duke@435: JavaThreadParkedState(JavaThread *java_thread, bool timed) : duke@435: JavaThreadStatusChanger(java_thread, duke@435: timed ? java_lang_Thread::PARKED_TIMED : java_lang_Thread::PARKED) { duke@435: if (is_alive()) { duke@435: _stat = java_thread->get_thread_stat(); duke@435: _active = ThreadService::is_thread_monitoring_contention(); duke@435: _stat->monitor_wait(); duke@435: if (_active) { duke@435: _stat->monitor_wait_begin(); duke@435: } duke@435: } else { duke@435: _active = false; duke@435: } duke@435: } duke@435: duke@435: ~JavaThreadParkedState() { duke@435: if (_active) { duke@435: _stat->monitor_wait_end(); duke@435: } duke@435: } duke@435: }; duke@435: duke@435: // Change status to blocked on (re-)entering a synchronization block duke@435: class JavaThreadBlockedOnMonitorEnterState : public JavaThreadStatusChanger { duke@435: private: duke@435: ThreadStatistics* _stat; duke@435: bool _active; duke@435: duke@435: static bool contended_enter_begin(JavaThread *java_thread) { duke@435: set_thread_status(java_thread, java_lang_Thread::BLOCKED_ON_MONITOR_ENTER); duke@435: ThreadStatistics* stat = java_thread->get_thread_stat(); duke@435: stat->contended_enter(); duke@435: bool active = ThreadService::is_thread_monitoring_contention(); duke@435: if (active) { duke@435: stat->contended_enter_begin(); duke@435: } duke@435: return active; duke@435: } duke@435: duke@435: public: duke@435: // java_thread is waiting thread being blocked on monitor reenter. duke@435: // Current thread is the notifying thread which holds the monitor. duke@435: static bool wait_reenter_begin(JavaThread *java_thread, ObjectMonitor *obj_m) { duke@435: assert((java_thread != NULL), "Java thread should not be null here"); duke@435: bool active = false; duke@435: if (is_alive(java_thread) && ServiceUtil::visible_oop((oop)obj_m->object())) { duke@435: active = contended_enter_begin(java_thread); duke@435: } duke@435: return active; duke@435: } duke@435: duke@435: static void wait_reenter_end(JavaThread *java_thread, bool active) { duke@435: if (active) { duke@435: java_thread->get_thread_stat()->contended_enter_end(); duke@435: } duke@435: set_thread_status(java_thread, java_lang_Thread::RUNNABLE); duke@435: } duke@435: duke@435: JavaThreadBlockedOnMonitorEnterState(JavaThread *java_thread, ObjectMonitor *obj_m) : duke@435: JavaThreadStatusChanger(java_thread) { duke@435: assert((java_thread != NULL), "Java thread should not be null here"); duke@435: // Change thread status and collect contended enter stats for monitor contended duke@435: // enter done for external java world objects and it is contended. All other cases duke@435: // like for vm internal objects and for external objects which are not contended duke@435: // thread status is not changed and contended enter stat is not collected. duke@435: _active = false; duke@435: if (is_alive() && ServiceUtil::visible_oop((oop)obj_m->object()) && obj_m->contentions() > 0) { duke@435: _stat = java_thread->get_thread_stat(); duke@435: _active = contended_enter_begin(java_thread); duke@435: } duke@435: } duke@435: duke@435: ~JavaThreadBlockedOnMonitorEnterState() { duke@435: if (_active) { duke@435: _stat->contended_enter_end(); duke@435: } duke@435: } duke@435: }; duke@435: duke@435: // Change status to sleeping duke@435: class JavaThreadSleepState : public JavaThreadStatusChanger { duke@435: private: duke@435: ThreadStatistics* _stat; duke@435: bool _active; duke@435: public: duke@435: JavaThreadSleepState(JavaThread *java_thread) : duke@435: JavaThreadStatusChanger(java_thread, java_lang_Thread::SLEEPING) { duke@435: if (is_alive()) { duke@435: _stat = java_thread->get_thread_stat(); duke@435: _active = ThreadService::is_thread_monitoring_contention(); duke@435: _stat->thread_sleep(); duke@435: if (_active) { duke@435: _stat->thread_sleep_begin(); duke@435: } duke@435: } else { duke@435: _active = false; duke@435: } duke@435: } duke@435: duke@435: ~JavaThreadSleepState() { duke@435: if (_active) { duke@435: _stat->thread_sleep_end(); duke@435: } duke@435: } duke@435: };