public abstract class JavaThreads extends Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
JavaThreads.ThreadStartData |
Modifier and Type | Field and Description |
---|---|
ThreadGroup |
systemGroup
The root group for all threads.
|
Modifier | Constructor and Description |
---|---|
protected |
JavaThreads() |
Modifier and Type | Method and Description |
---|---|
static void |
assignJavaThread(Thread thread,
boolean manuallyStarted)
|
protected void |
beforeThreadRun(Thread thread)
Hook for subclasses.
|
static boolean |
currentJavaThreadInitialized()
Returns true if the
Thread object for the current thread exists. |
static void |
detachThread(org.graalvm.nativeimage.IsolateThread vmThread)
Detach the provided Java thread.
|
static void |
dispatchUncaughtException(Thread thread,
Throwable throwable)
If there is an uncaught exception handler, call it.
|
protected abstract void |
doStartThread(Thread thread,
long stackSize)
Start a new OS thread.
|
static boolean |
ensureJavaThread()
Ensures that a
Thread object for the current thread exists. |
static boolean |
ensureJavaThread(String name,
ThreadGroup group,
boolean asDaemon)
Ensures that a
Thread object for the current thread exists. |
protected static void |
exit(Thread thread) |
static Thread |
fromVMThread(org.graalvm.nativeimage.IsolateThread vmThread) |
protected static UninterruptibleUtils.AtomicReference<ParkEvent> |
getSleepParkEvent(Thread thread) |
static int |
getThreadStatus(Thread thread) |
protected static UninterruptibleUtils.AtomicReference<ParkEvent> |
getUnsafeParkEvent(Thread thread) |
void |
initializeIsolate() |
void |
joinAllNonDaemons()
Joins all non-daemon threads.
|
protected void |
prepareStartData(Thread thread,
JavaThreads.ThreadStartData startData) |
protected abstract void |
setNativeName(Thread thread,
String name)
Set the OS-level name of the thread.
|
static void |
setThreadStatus(Thread thread,
int threadStatus) |
static JavaThreads |
singleton() |
boolean |
tearDown()
Tear down all application threads (except the current one).
|
protected static void |
threadStartRoutine(org.graalvm.nativeimage.ObjectHandle threadHandle) |
protected static void |
wakeUpVMConditionWaiters(Thread thread)
Wake a thread which is waiting by other means, such as VM-internal condition variables, so
that they can check their interrupted status.
|
protected static boolean |
wasStartedByCurrentIsolate(org.graalvm.nativeimage.IsolateThread thread) |
protected static boolean |
wasStartedByCurrentIsolate(Thread thread) |
protected abstract void |
yield() |
public final ThreadGroup systemGroup
public static JavaThreads singleton()
public static int getThreadStatus(Thread thread)
public static void setThreadStatus(Thread thread, int threadStatus)
protected static UninterruptibleUtils.AtomicReference<ParkEvent> getUnsafeParkEvent(Thread thread)
protected static UninterruptibleUtils.AtomicReference<ParkEvent> getSleepParkEvent(Thread thread)
protected static boolean wasStartedByCurrentIsolate(org.graalvm.nativeimage.IsolateThread thread)
protected static boolean wasStartedByCurrentIsolate(Thread thread)
public static Thread fromVMThread(org.graalvm.nativeimage.IsolateThread vmThread)
public void joinAllNonDaemons()
public static boolean currentJavaThreadInitialized()
Thread
object for the current thread exists. This method only
returns false in the very early initialization stages of a newly attached thread.public static boolean ensureJavaThread()
Thread
object for the current thread exists. If a Thread
already exists, this method is a no-op. The current thread must have already been attached.Thread
object had already been
assigned.public static boolean ensureJavaThread(String name, ThreadGroup group, boolean asDaemon)
Thread
object for the current thread exists. If a Thread
already exists, this method is a no-op. The current thread must have already been attached.name
- the thread's name, or null
for a default name.group
- the thread group, or null
for the default thread group.asDaemon
- the daemon status of the new thread.Thread
object had already been
assigned.public static void assignJavaThread(Thread thread, boolean manuallyStarted)
Thread
object to the current thread, which must have already been attached
VMThreads
as an IsolateThread
.
The manuallyStarted parameter is true if this thread was started directly by calling
assignJavaThread(Thread). It is false when the thread is started using
PosixJavaThreads.pthreadStartRoutine, e.g., called from PosixJavaThreads.start0.public void initializeIsolate()
public boolean tearDown()
CEntryPoint
exit action.public static void detachThread(org.graalvm.nativeimage.IsolateThread vmThread)
protected static void exit(Thread thread)
protected void prepareStartData(Thread thread, JavaThreads.ThreadStartData startData)
protected abstract void doStartThread(Thread thread, long stackSize)
JavaThreads.prepareStartData(java.lang.Thread, com.oracle.svm.core.thread.JavaThreads.ThreadStartData)
after
preparations and before starting the thread. The new OS thread must call
JavaThreads.threadStartRoutine(org.graalvm.nativeimage.ObjectHandle)
.protected static void threadStartRoutine(org.graalvm.nativeimage.ObjectHandle threadHandle)
protected void beforeThreadRun(Thread thread)
protected abstract void setNativeName(Thread thread, String name)
protected abstract void yield()
protected static void wakeUpVMConditionWaiters(Thread thread)