--- a/src/hotspot/share/runtime/thread.hpp Tue Aug 28 14:45:34 2018 -0400
+++ b/src/hotspot/share/runtime/thread.hpp Tue Aug 28 16:04:54 2018 -0400
@@ -93,16 +93,21 @@
// Class hierarchy
// - Thread
-// - NamedThread
-// - VMThread
-// - ConcurrentGCThread
-// - WorkerThread
-// - GangWorker
-// - GCTaskThread
// - JavaThread
// - various subclasses eg CompilerThread, ServiceThread
-// - WatcherThread
-// - JfrSamplerThread
+// - NonJavaThread
+// - NamedThread
+// - VMThread
+// - ConcurrentGCThread
+// - WorkerThread
+// - GangWorker
+// - GCTaskThread
+// - WatcherThread
+// - JfrThreadSampler
+//
+// All Thread subclasses must be either JavaThread or NonJavaThread.
+// This means !t->is_Java_thread() iff t is a NonJavaThread, or t is
+// a partially constructed/destroyed Thread.
class Thread: public ThreadShadow {
friend class VMStructs;
@@ -380,7 +385,7 @@
// Constructor
Thread();
- virtual ~Thread();
+ virtual ~Thread() = 0; // Thread is abstract.
// Manage Thread::current()
void initialize_thread_current();
@@ -764,9 +769,47 @@
return NULL;
}
+class NonJavaThread: public Thread {
+ friend class VMStructs;
+
+ NonJavaThread* volatile _next;
+
+ class List;
+ static List _the_list;
+
+ public:
+ NonJavaThread();
+ ~NonJavaThread();
+
+ class Iterator;
+};
+
+// Provides iteration over the list of NonJavaThreads. Because list
+// management occurs in the NonJavaThread constructor and destructor,
+// entries in the list may not be fully constructed instances of a
+// derived class. Threads created after an iterator is constructed
+// will not be visited by the iterator. The scope of an iterator is a
+// critical section; there must be no safepoint checks in that scope.
+class NonJavaThread::Iterator : public StackObj {
+ uint _protect_enter;
+ NonJavaThread* _current;
+
+ // Noncopyable.
+ Iterator(const Iterator&);
+ Iterator& operator=(const Iterator&);
+
+public:
+ Iterator();
+ ~Iterator();
+
+ bool end() const { return _current == NULL; }
+ NonJavaThread* current() const { return _current; }
+ void step();
+};
+
// Name support for threads. non-JavaThread subclasses with multiple
// uniquely named instances should derive from this.
-class NamedThread: public Thread {
+class NamedThread: public NonJavaThread {
friend class VMStructs;
enum {
max_name_len = 64
@@ -776,10 +819,6 @@
// log JavaThread being processed by oops_do
JavaThread* _processed_thread;
uint _gc_id; // The current GC id when a thread takes part in GC
- NamedThread* volatile _next_named_thread;
-
- class List;
- static List _the_list;
public:
NamedThread();
@@ -795,31 +834,6 @@
void set_gc_id(uint gc_id) { _gc_id = gc_id; }
uint gc_id() { return _gc_id; }
-
- class Iterator;
-};
-
-// Provides iteration over the list of NamedThreads. Because list
-// management occurs in the NamedThread constructor and destructor,
-// entries in the list may not be fully constructed instances of a
-// derived class. Threads created after an iterator is constructed
-// will not be visited by the iterator. The scope of an iterator is a
-// critical section; there must be no safepoint checks in that scope.
-class NamedThread::Iterator : public StackObj {
- uint _protect_enter;
- NamedThread* _current;
-
- // Noncopyable.
- Iterator(const Iterator&);
- Iterator& operator=(const Iterator&);
-
-public:
- Iterator();
- ~Iterator();
-
- bool end() const { return _current == NULL; }
- NamedThread* current() const { return _current; }
- void step();
};
// Worker threads are named and have an id of an assigned work.
@@ -840,7 +854,7 @@
};
// A single WatcherThread is used for simulating timer interrupts.
-class WatcherThread: public Thread {
+class WatcherThread: public NonJavaThread {
friend class VMStructs;
public:
virtual void run();