< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page




 497   // Casts
 498   virtual WorkerThread* as_Worker_thread() const     { return NULL; }
 499 
 500   virtual char* name() const { return (char*)"Unknown thread"; }
 501 
 502   // Returns the current thread (ASSERTS if NULL)
 503   static inline Thread* current();
 504   // Returns the current thread, or NULL if not attached
 505   static inline Thread* current_or_null();
 506   // Returns the current thread, or NULL if not attached, and is
 507   // safe for use from signal-handlers
 508   static inline Thread* current_or_null_safe();
 509 
 510   // Common thread operations
 511 #ifdef ASSERT
 512   static void check_for_dangling_thread_pointer(Thread *thread);
 513 #endif
 514   static void set_priority(Thread* thread, ThreadPriority priority);
 515   static ThreadPriority get_priority(const Thread* const thread);
 516   static void start(Thread* thread);
 517   static void interrupt(Thread* thr);
 518   static bool is_interrupted(Thread* thr, bool clear_interrupted);
 519 
 520   void set_native_thread_name(const char *name) {
 521     assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
 522     os::set_native_thread_name(name);
 523   }
 524 
 525   ObjectMonitor** om_in_use_list_addr()          { return (ObjectMonitor **)&om_in_use_list; }
 526   Monitor* SR_lock() const                       { return _SR_lock; }
 527 
 528   bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
 529 
 530   inline void set_suspend_flag(SuspendFlags f);
 531   inline void clear_suspend_flag(SuspendFlags f);
 532 
 533   inline void set_has_async_exception();
 534   inline void clear_has_async_exception();
 535 
 536   bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
 537 
 538   inline void set_critical_native_unlock();


2038   GrowableArray<MonitorInfo*>* _cached_monitor_info;
2039  public:
2040   GrowableArray<MonitorInfo*>* cached_monitor_info() { return _cached_monitor_info; }
2041   void set_cached_monitor_info(GrowableArray<MonitorInfo*>* info) { _cached_monitor_info = info; }
2042 
2043   // clearing/querying jni attach status
2044   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
2045   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
2046   inline void set_done_attaching_via_jni();
2047 
2048   // Stack dump assistance:
2049   // Track the class we want to initialize but for which we have to wait
2050   // on its init_lock() because it is already being initialized.
2051   void set_class_to_be_initialized(InstanceKlass* k);
2052   InstanceKlass* class_to_be_initialized() const;
2053 
2054 private:
2055   InstanceKlass* _class_to_be_initialized;
2056 
2057   // java.lang.Thread.sleep support
2058 public:
2059   ParkEvent * _SleepEvent;

2060   bool sleep(jlong millis);





2061 };
2062 
2063 // Inline implementation of JavaThread::current
2064 inline JavaThread* JavaThread::current() {
2065   Thread* thread = Thread::current();
2066   assert(thread->is_Java_thread(), "just checking");
2067   return (JavaThread*)thread;
2068 }
2069 
2070 inline CompilerThread* JavaThread::as_CompilerThread() {
2071   assert(is_Compiler_thread(), "just checking");
2072   return (CompilerThread*)this;
2073 }
2074 
2075 // Dedicated thread to sweep the code cache
2076 class CodeCacheSweeperThread : public JavaThread {
2077   CompiledMethod*       _scanned_compiled_method; // nmethod being scanned by the sweeper
2078  public:
2079   CodeCacheSweeperThread();
2080   // Track the nmethod currently being scanned by the sweeper




 497   // Casts
 498   virtual WorkerThread* as_Worker_thread() const     { return NULL; }
 499 
 500   virtual char* name() const { return (char*)"Unknown thread"; }
 501 
 502   // Returns the current thread (ASSERTS if NULL)
 503   static inline Thread* current();
 504   // Returns the current thread, or NULL if not attached
 505   static inline Thread* current_or_null();
 506   // Returns the current thread, or NULL if not attached, and is
 507   // safe for use from signal-handlers
 508   static inline Thread* current_or_null_safe();
 509 
 510   // Common thread operations
 511 #ifdef ASSERT
 512   static void check_for_dangling_thread_pointer(Thread *thread);
 513 #endif
 514   static void set_priority(Thread* thread, ThreadPriority priority);
 515   static ThreadPriority get_priority(const Thread* const thread);
 516   static void start(Thread* thread);


 517 
 518   void set_native_thread_name(const char *name) {
 519     assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
 520     os::set_native_thread_name(name);
 521   }
 522 
 523   ObjectMonitor** om_in_use_list_addr()          { return (ObjectMonitor **)&om_in_use_list; }
 524   Monitor* SR_lock() const                       { return _SR_lock; }
 525 
 526   bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
 527 
 528   inline void set_suspend_flag(SuspendFlags f);
 529   inline void clear_suspend_flag(SuspendFlags f);
 530 
 531   inline void set_has_async_exception();
 532   inline void clear_has_async_exception();
 533 
 534   bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
 535 
 536   inline void set_critical_native_unlock();


2036   GrowableArray<MonitorInfo*>* _cached_monitor_info;
2037  public:
2038   GrowableArray<MonitorInfo*>* cached_monitor_info() { return _cached_monitor_info; }
2039   void set_cached_monitor_info(GrowableArray<MonitorInfo*>* info) { _cached_monitor_info = info; }
2040 
2041   // clearing/querying jni attach status
2042   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
2043   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
2044   inline void set_done_attaching_via_jni();
2045 
2046   // Stack dump assistance:
2047   // Track the class we want to initialize but for which we have to wait
2048   // on its init_lock() because it is already being initialized.
2049   void set_class_to_be_initialized(InstanceKlass* k);
2050   InstanceKlass* class_to_be_initialized() const;
2051 
2052 private:
2053   InstanceKlass* _class_to_be_initialized;
2054 
2055   // java.lang.Thread.sleep support

2056   ParkEvent * _SleepEvent;
2057 public:
2058   bool sleep(jlong millis);
2059 
2060   // java.lang.Thread interruption support
2061   void interrupt();
2062   bool is_interrupted(bool clear_interrupted);
2063 
2064 };
2065 
2066 // Inline implementation of JavaThread::current
2067 inline JavaThread* JavaThread::current() {
2068   Thread* thread = Thread::current();
2069   assert(thread->is_Java_thread(), "just checking");
2070   return (JavaThread*)thread;
2071 }
2072 
2073 inline CompilerThread* JavaThread::as_CompilerThread() {
2074   assert(is_Compiler_thread(), "just checking");
2075   return (CompilerThread*)this;
2076 }
2077 
2078 // Dedicated thread to sweep the code cache
2079 class CodeCacheSweeperThread : public JavaThread {
2080   CompiledMethod*       _scanned_compiled_method; // nmethod being scanned by the sweeper
2081  public:
2082   CodeCacheSweeperThread();
2083   // Track the nmethod currently being scanned by the sweeper


< prev index next >