public final class UtlThread extends Object
This class IS supported for use by end users..
| Modifier and Type | Class and Description |
|---|---|
static class |
UtlThread.ThreadStats
Used by a thread to track stats related to its execution.
|
| Constructor and Description |
|---|
UtlThread() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
cpuAffinityMasksEnabled()
Returns whether CPU affinitization is enabled or not
|
static String |
decodeAffinityMask(long mask)
Returns a mask string for the given mask.
|
static String |
decodeAffinityMask(long mask,
boolean physicalFormat)
Decodes an affinity mask into a string format.
|
static void |
deregister(Thread thread)
Can be called to stop tracking the specified thread.
|
static void |
dumpAffinitizationState(Appendable to,
String prefix)
Dumps thread affinitization information.
|
static void |
dumpProcessorLayout(Appendable to)
Dumps the processor layout to the provided
Appendable |
static Thread[] |
getAllThreads()
Gets all running threads in the JVM.
|
static String |
getDefaultCPUAffinityMask()
Get the default CPU affinity mask
|
static UtlThread.ThreadStats |
getThreadStats(Thread thread)
Gets the thread stats for the given thread.
|
static void |
main(String[] args) |
static int |
nativeGetThreadStats(long[] threadIds,
long[] cpuTimes,
long[] userTimes,
int[] threadStates,
char[][] threadNames,
int[] threadNameLengths)
Bulk retrieval of per-thread stats from the OS via native code.
|
static long |
parseAffinityMask(String affinity)
Parses a mask string into a mask value.
|
static UtlThread.ThreadStats |
registerOrGetThreadStats(Thread thread)
Can be called to register a thread for tracking.
|
static void |
setCPUAffinityMask(long mask)
Sets the CPU affinity mask of the current thread.
|
static void |
setCPUAffinityMask(String affinity)
Sets the CPU affinity mask of the current thread.
|
static void |
setDefaultCPUAffinityMask()
Set the CPU affinity mask of the current thread to the default mask
|
static boolean |
threadWaitStatsEnabled()
Returns whether thread wait stats are enabled.
|
static void |
triggerThreadDump(Appendable output)
Creates a stack dump.
|
public static final UtlThread.ThreadStats registerOrGetThreadStats(Thread thread)
The caller should call deregister(Thread) when the thread
is longer in use.
thread - The thread to register or null if thread stats are not enabled.public static void deregister(Thread thread)
thread - The thread to deregister.public static final boolean cpuAffinityMasksEnabled()
public static final boolean threadWaitStatsEnabled()
public static final void setCPUAffinityMask(long mask)
mask - The affinity mask to set.public static void setCPUAffinityMask(String affinity)
affinity - The affinity mask to set in the form described by parseAffinityMask(String).parseAffinityMask(String)public static String getDefaultCPUAffinityMask()
public static void setDefaultCPUAffinityMask()
public static long parseAffinityMask(String affinity)
Examples:
affinity - The string describing the affinity maskpublic static final String decodeAffinityMask(long mask)
mask - The mask to decodeparseAffinityMask(String).public static final String decodeAffinityMask(long mask, boolean physicalFormat)
mask - The mask The mask to decode.physicalFormat - Attempts to resolve the cores to physical format for the given machine,public static final void dumpProcessorLayout(Appendable to)
Appendableto - The target to which to dump the processor layout.public static final void dumpAffinitizationState(Appendable to, String prefix)
to - The target to which to dump the affinization state.public static final UtlThread.ThreadStats getThreadStats(Thread thread)
thread - The thread for which to retrieve stats.parseAffinityMask(String)public static final Thread[] getAllThreads()
This method may be used by end users, but is not supported and is subject to change
public static void triggerThreadDump(Appendable output)
This method may be used by end users, but is not supported and is subject to change
output - the appendable to which to append the dump.public static final int nativeGetThreadStats(long[] threadIds,
long[] cpuTimes,
long[] userTimes,
int[] threadStates,
char[][] threadNames,
int[] threadNameLengths)
All arrays must be pre-allocated by the caller. This method fills them with thread data and returns the number of threads populated. This is a zero-garbage operation: no Java heap allocations are made by the native code.
On platforms where native thread stats are not supported (e.g. Windows), this method returns 0.
threadIds - OUT: OS thread ID per threadcpuTimes - OUT: total CPU time in nanoseconds per threaduserTimes - OUT: user-mode CPU time in nanoseconds per threadthreadStates - OUT: thread state ordinal per thread (0=RUNNING, 1=SLEEPING, 2=DISK_SLEEP, 3=STOPPED, 4=ZOMBIE, 5=UNKNOWN)threadNames - OUT: pre-allocated char[] per thread slot, filled with thread name charsthreadNameLengths - OUT: actual length of each thread namepublic static final void main(String[] args)
Copyright © 2019 N5 Technologies, Inc. All Rights Reserved.