|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jaw.impl.agent.services.light.ThreadAllocatorSrv
This class provides a simple implementation of a thread allocator.
It returns a new Thread()
to the requestor.
M-beans can get a pointer to the thread allocator service through the framework object
using the ThreadAllocatorSrvIf getThreadAllocatorSrvIf()
public method.
The ThreadAllocatorSrvIf
interface defines Thread obtainThread(...)
methods that
follow Thread constructor prototypes with
one additional parameter, named requestorId
(java.lang.Object
), that identifies
the requestor.
M-Beans and services of JDMK use their ObjectName as requestor identifier.
Runnable
,
Thread
,
ThreadAllocatorSrvIf
Constructor Summary | |
ThreadAllocatorSrv()
|
Method Summary | |
java.lang.String[] |
getActiveThreadNameArray()
Returns an array containing all names of active Thread. |
java.lang.Thread |
obtainThread(java.lang.Object requestorId)
Allocates a new Thread object. |
java.lang.Thread |
obtainThread(java.lang.Object requestorId,
java.lang.Runnable target)
Allocates a new Thread object. |
java.lang.Thread |
obtainThread(java.lang.Object requestorId,
java.lang.Runnable target,
java.lang.String name)
Allocates a new Thread object. |
java.lang.Thread |
obtainThread(java.lang.Object requestorId,
java.lang.String name)
Allocates a new Thread object. |
java.lang.Thread |
obtainThread(java.lang.Object requestorId,
java.lang.ThreadGroup group,
java.lang.Runnable target)
Allocates a new Thread object. |
java.lang.Thread |
obtainThread(java.lang.Object requestorId,
java.lang.ThreadGroup group,
java.lang.Runnable target,
java.lang.String name)
Allocates a new Thread object with
requestorId as the requestor identifier,
target as its run object, and the specified
name as its name; the thread is assigned to the thread group
referred to by group . |
java.lang.Thread |
obtainThread(java.lang.Object requestorId,
java.lang.ThreadGroup group,
java.lang.String name)
Allocates a new Thread object. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ThreadAllocatorSrv()
Method Detail |
public java.lang.Thread obtainThread(java.lang.Object requestorId)
Thread
object. This method has
the same effect as obtainThread(requestorId, null, null,
gname)
, where gname is
an automatically generated name. Automatically generated names are of the
form "Thread-"+
n, where n is an integer.
Threads created this way must have overridden their
run
method to actually do anything. An example
illustrating this method being used follows:
class threadtest { public threadtest() { } public void initCmf(Framework cmf,ObjectName name){ Thread t1 = cmf.getThreadAllocatorSrvIf().obtainThread(name); if (t1 != null){ System.out.println("new Thread() succeed"); cmf.addObject(this, name); } else { System.out.println("new Thread() failed"); } }
resquestorId
- The requestor's identifier.obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
public java.lang.Thread obtainThread(java.lang.Object requestorId, java.lang.Runnable target)
Thread
object. This method has
the same effect as obtainThread(requestorId, null, target,
gname)
, where gname is
an automatically generated name. Automatically generated names are of the
form "Thread-"+
n, where n is an integer.resquestorId
- The requestor's identifier.target
- the object whose run
method is called.obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
public java.lang.Thread obtainThread(java.lang.Object requestorId, java.lang.ThreadGroup group, java.lang.Runnable target)
Thread
object. This method has
the same effect as obtainThread(requestorId, group, target,
gname)
, where gname is
an automatically generated name. Automatically generated names are of the
form "Thread-"+
n, where n is an integer.resquestorId
- The requestor's identifier.group
- the thread group.target
- the object whose run
method is called.obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
public java.lang.Thread obtainThread(java.lang.Object requestorId, java.lang.String name)
Thread
object. This method has
the same effect as obtainThread(requestorId, null, null, name)
.resquestorId
- The requestor's identifier.name
- the name of the new thread.obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
public java.lang.Thread obtainThread(java.lang.Object requestorId, java.lang.ThreadGroup group, java.lang.String name)
Thread
object. This method has
the same effect as obtainThread(requestorId, group, null, name)
resquestorId
- The requestor's identifier.group
- the thread group.name
- the name of the new thread.obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
public java.lang.Thread obtainThread(java.lang.Object requestorId, java.lang.Runnable target, java.lang.String name)
Thread
object. This method has
the same effect as obtainThread(requestorId, null, target, name)
.resquestorId
- The requestor's identifier.target
- the object whose run
method is called.name
- the name of the new thread.obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)
public java.lang.Thread obtainThread(java.lang.Object requestorId, java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
Thread
object with
requestorId
as the requestor identifier,
target
as its run object, and the specified
name
as its name; the thread is assigned to the thread group
referred to by group
.
If group
is not null
, the
checkAccess
method of that thread group is called with
no arguments; this may result in throwing a
SecurityException
. If group
is
null
, the new process belongs to the same group as
the thread that is creating the new thread.
If the target
argument is not null
, the
run
method of the target
is called when
this thread is started. If the target argument is
null
, this thread's run
method is called
when this thread is started.
The priority of the newly created thread is set equal to the
priority of the thread creating it, that is, the currently running
thread. The method setPriority
may be used to
change the priority to a new value.
The newly created thread is initially marked as being a daemon
thread if and only if the thread creating it is currently marked
as a daemon thread. The method setDaemon
may be used
to change whether or not a thread is a daemon.
resquestorId
- The requestor's identifier.group
- the thread group.target
- the object whose run
method is called.name
- the name of the new thread.public java.lang.String[] getActiveThreadNameArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |