APIdia Launch Partner
Top Description Fields Constructors Methods
sun.rmi.runtime

public final Class RuntimeUtil

extends Object
Class Inheritance
Imports
java.util.concurrent.ScheduledThreadPoolExecutor, .ThreadFactory, java.util.concurrent.atomic.AtomicInteger, java.util.logging.Level

RMI runtime implementation utilities. There is a single instance of this class, which can be obtained with a getInstance() call. This class also contains a couple static methods for creating threads. The methods allow the choice of the Runnable for the new thread to execute, the name of the new thread (which will be prefixed with "RMI "), and whether or not it will be a daemon thread. The new thread may be created in the system thread group (the root of the thread group tree) or an internally created non-system thread group (the "user" thread group). The new thread will have the system class loader as its initial context class loader (that is, its context class loader will NOT be inherited from the current thread).
Author
Peter Jones

Field Summary

Modifier and TypeField and Description
private static final RuntimeUtil
instance

the singleton instance of this class

private static final Log
runtimeLog

runtime package log

private final ScheduledThreadPoolExecutor
scheduler

thread pool for scheduling delayed tasks

private static final int
schedulerThreads

number of scheduler threads

private static final ThreadGroup
systemThreadGroup

Cached reference to the system (root) thread group.

private static final ThreadGroup
userThreadGroup

Special child of the system thread group for running tasks that may execute user code.

Constructor Summary

AccessConstructor and Description
private
RuntimeUtil()

Creates the single instance of RuntimeUtil.

Method Summary

Modifier and TypeMethod and Description
public static RuntimeUtil
public ScheduledThreadPoolExecutor
getScheduler()

Returns the shared thread pool for scheduling delayed tasks.

public static Thread

Returns:

the newly created thread
newSystemThread
(Runnable
the thread's task
runnable
,
String
the thread's name, which will be prefixed with "RMI "
name
,
boolean
whether the thread should be a daemon
daemon
)

Creates and returns, but does not start, a new thread with the given settings.

private static Thread

Returns:

the newly created thread
newThread
(ThreadGroup
the thread group, should be systemThreadGroup or userThreadGroup
group
,
Runnable
the thread's task
runnable
,
String
the thread's name, which will be prefixed with "RMI "
name
,
boolean
whether the thread should be a daemon
daemon
)

Internal method to create a new thread with the given settings.

public static Thread

Returns:

the newly created thread
newUserThread
(Runnable
the thread's task
runnable
,
String
the thread's name, which will be prefixed with "RMI "
name
,
boolean
whether the thread should be a daemon
daemon
)

Creates and returns, but does not start, a new thread with the given settings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
private static final RuntimeUtil instance

the singleton instance of this class

runtimeLogback to summary
private static final Log runtimeLog

runtime package log

schedulerback to summary
private final ScheduledThreadPoolExecutor scheduler

thread pool for scheduling delayed tasks

schedulerThreadsback to summary
private static final int schedulerThreads

number of scheduler threads

systemThreadGroupback to summary
private static final ThreadGroup systemThreadGroup

Cached reference to the system (root) thread group.

userThreadGroupback to summary
private static final ThreadGroup userThreadGroup

Special child of the system thread group for running tasks that may execute user code. The need for a separate thread group may be a vestige of it having had a different security policy from the system thread group, so this might no longer be necessary.

Constructor Detail

RuntimeUtilback to summary
private RuntimeUtil()

Creates the single instance of RuntimeUtil. Note that this is called from a static initializer, and it has a ThreadFactory that calls static methods on this class, possibly from other threads. This should be ok, as the ScheduledThreadPoolExecutor constructor returns immediately without blocking on the creation of threads by the factory.

Method Detail

getInstanceback to summary
public static RuntimeUtil getInstance()
getSchedulerback to summary
public ScheduledThreadPoolExecutor getScheduler()

Returns the shared thread pool for scheduling delayed tasks. Note that the returned pool has limited concurrency, so submitted tasks should be short-lived and should not block.

newSystemThreadback to summary
public static Thread newSystemThread(Runnable runnable, String name, boolean daemon)

Creates and returns, but does not start, a new thread with the given settings. The thread will be in the system ("root") thread group.

Parameters
runnable:Runnable

the thread's task

name:String

the thread's name, which will be prefixed with "RMI "

daemon:boolean

whether the thread should be a daemon

Returns:Thread

the newly created thread

newThreadback to summary
private static Thread newThread(ThreadGroup group, Runnable runnable, String name, boolean daemon)

Internal method to create a new thread with the given settings.

Parameters
group:ThreadGroup

the thread group, should be systemThreadGroup or userThreadGroup

runnable:Runnable

the thread's task

name:String

the thread's name, which will be prefixed with "RMI "

daemon:boolean

whether the thread should be a daemon

Returns:Thread

the newly created thread

newUserThreadback to summary
public static Thread newUserThread(Runnable runnable, String name, boolean daemon)

Creates and returns, but does not start, a new thread with the given settings. The thread will be in the RMI user thread group.

Parameters
runnable:Runnable

the thread's task

name:String

the thread's name, which will be prefixed with "RMI "

daemon:boolean

whether the thread should be a daemon

Returns:Thread

the newly created thread