public abstract class JavaThreads extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
JavaThreads.ThreadStartData |
| Modifier and Type | Field and Description |
|---|---|
protected static FastThreadLocalObject<Thread> |
currentThread
The
Thread for the IsolateThread. |
protected AtomicInteger |
daemonThreads |
protected AtomicInteger |
liveThreads |
protected AtomicInteger |
nonDaemonThreads |
protected AtomicInteger |
peakThreads |
protected AtomicLong |
totalThreads |
| Constructor and Description |
|---|
JavaThreads() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
assignJavaThread(String name,
ThreadGroup group,
boolean asDaemon)
Create a
Thread object for the current thread. |
boolean |
assignJavaThread(Thread thread,
boolean manuallyStarted)
|
Thread |
createIfNotExisting(org.graalvm.nativeimage.IsolateThread vmThread) |
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.
|
protected static void |
exit(Thread thread) |
Thread |
fromVMThread(org.graalvm.nativeimage.IsolateThread vmThread) |
static Thread |
getCurrentThread() |
int |
getDaemonThreads() |
int |
getLiveThreads() |
int |
getPeakThreads() |
protected static UninterruptibleUtils.AtomicReference<ParkEvent> |
getSleepParkEvent(Thread thread) |
static int |
getThreadStatus(Thread thread) |
long |
getTotalThreads() |
protected static UninterruptibleUtils.AtomicReference<ParkEvent> |
getUnsafeParkEvent(Thread thread) |
protected static void |
interruptVMCondVars() |
void |
joinAllNonDaemons()
Joins all non-daemon threads.
|
protected void |
noteThreadFinish(Thread thread) |
protected void |
noteThreadStart(Thread thread) |
protected static 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) |
void |
signalNonDaemonThreadStart()
Signal that a thread was started by calling Thread.start().
|
static JavaThreads |
singleton() |
boolean |
tearDownVM()
Tear down the VMThreads.
|
protected static void |
threadStartRoutine(org.graalvm.nativeimage.ObjectHandle threadHandle) |
protected abstract void |
yield() |
protected static final FastThreadLocalObject<Thread> currentThread
protected final AtomicLong totalThreads
protected final AtomicInteger peakThreads
protected final AtomicInteger liveThreads
protected final AtomicInteger daemonThreads
protected final AtomicInteger nonDaemonThreads
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)
public Thread fromVMThread(org.graalvm.nativeimage.IsolateThread vmThread)
public static Thread getCurrentThread()
public Thread createIfNotExisting(org.graalvm.nativeimage.IsolateThread vmThread)
public long getTotalThreads()
public int getPeakThreads()
public int getLiveThreads()
public int getDaemonThreads()
public void joinAllNonDaemons()
public void signalNonDaemonThreadStart()
public boolean assignJavaThread(String name, ThreadGroup group, boolean asDaemon)
Thread object for the current thread. The current thread must have already
been attached VMThreads as an IsolateThread.name - the thread's name, or null for a default name.group - the thread group, or null for the default thread group.Thread object has already been assigned.public boolean 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.Thread object has already been assigned.public boolean tearDownVM()
This is called from an CEntryPoint exit action.
Returns true if the VM has been torn down, false otherwise.
public static void detachThread(org.graalvm.nativeimage.IsolateThread vmThread)
protected static void exit(Thread thread)
protected static 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 noteThreadStart(Thread thread)
protected void noteThreadFinish(Thread thread)
protected abstract void setNativeName(Thread thread, String name)
protected abstract void yield()
protected static void interruptVMCondVars()