com.sun.jaw.reference.agent.services
Interface ThreadAllocatorSrvIf

All Known Implementing Classes:
ThreadAllocatorSrv

public abstract interface ThreadAllocatorSrvIf

This interface provides a means for implementing a thread allocator service.

A thread allocator service is used by the framework for controlling thread allocation

See Also:
Runnable, Thread

Method Summary
 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, 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.
 

Method Detail

obtainThread

public java.lang.Thread obtainThread(java.lang.Object requestorId)
Allocates a new 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"); 
             }
         }

 
Parameters:
resquestorId - The requestor's identifier
See Also:
obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)

obtainThread

public java.lang.Thread obtainThread(java.lang.Object requestorId,
                                     java.lang.Runnable target)
Allocates a new 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.
Parameters:
resquestorId - The requestor's identifier
target - the object whose run method is called.
See Also:
obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)

obtainThread

public java.lang.Thread obtainThread(java.lang.Object requestorId,
                                     java.lang.ThreadGroup group,
                                     java.lang.Runnable target)
Allocates a new 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.
Parameters:
resquestorId - The requestor's identifier
group - the thread group.
target - the object whose run method is called.
Throws:
java.lang.SecurityException - if the current thread cannot create a thread in the specified thread group.
See Also:
obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)

obtainThread

public java.lang.Thread obtainThread(java.lang.Object requestorId,
                                     java.lang.String name)
Allocates a new Thread object. This method has the same effect as obtainThread(requestorId, null, null, name).
Parameters:
resquestorId - The requestor's identifier
name - the name of the new thread.
See Also:
obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)

obtainThread

public java.lang.Thread obtainThread(java.lang.Object requestorId,
                                     java.lang.ThreadGroup group,
                                     java.lang.String name)
Allocates a new Thread object. This method has the same effect as obtainThread(requestorId, group, null, name)
Parameters:
resquestorId - The requestor's identifier
group - the thread group.
name - the name of the new thread.
Throws:
java.lang.SecurityException - if the current thread cannot create a thread in the specified thread group.
See Also:
obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)

obtainThread

public java.lang.Thread obtainThread(java.lang.Object requestorId,
                                     java.lang.Runnable target,
                                     java.lang.String name)
Allocates a new Thread object. This method has the same effect as obtainThread(requestorId, null, target, name).
Parameters:
resquestorId - The requestor's identifier
target - the object whose run method is called.
name - the name of the new thread.
See Also:
obtainThread(java.lang.Object, java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)

obtainThread

public 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, 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.

Parameters:
resquestorId - The requestor's identifier
group - the thread group.
target - the object whose run method is called.
name - the name of the new thread.
Throws:
java.lang.SecurityException - if the current thread cannot create a thread in the specified thread group.