Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

junk.system
Class JXThread  view JXThread download JXThread.java

java.lang.Object
  extended byjunk.system.JXThread
All Implemented Interfaces:
java.lang.Runnable

public final class JXThread
extends java.lang.Object
implements java.lang.Runnable

JXThread is design to allow for a parallel execution environment. Each created JXThread can be tracked and administered to by JUNK. JUNK uses the JXThread to dedicate each task that was requested by a client into a separate execution path such that parallel computation is achievable. It will also reduce the possibility of a performance bottle neck situation in JUNK. A JD4X thread is defined by a valid module and a valid task request to that module. If both the module and the task is valid than useful work can be done else the state of the thread is considered to be invalid and no useful work can be initiated at all.

Since:
JD4X 1.0
Version:
0.1, 03/06/2002

Field Summary
private  arch.message.error.JXError error
          The error generated by this thread
private  junk.util.ds.PriorityQueue idleQ
          Reference to external idle queue.
private  boolean isIdle
          Indicator for idle thread
private  boolean isKill
          Indicator for killing the thread
private  arch.module.major.JXMajorModule module
          The reference to the module in which the task is to be done
private  arch.task.JXTask task
          The reference to the requested task for the module
 
Constructor Summary
JXThread(arch.module.major.JXMajorModule m, arch.task.JXTask t)
          Create the default thread with a defined module and task.
JXThread(arch.module.major.JXMajorModule m, arch.task.JXTask t, junk.util.ds.PriorityQueue q)
          Create the default thread with a defined module and task with an external idle queue.
 
Method Summary
 arch.message.error.JXError getError()
           
 boolean isIdle()
          Tests if this thread is idle.
 boolean isKill()
          Tests if this thread has been terminated.
 void kill()
          To kill the thread.
 boolean reTask(arch.module.major.JXMajorModule m, arch.task.JXTask t)
          Assign a new task to the thread.
 void run()
          Encapsulates a request to a module to do a commit for a task into a separate threaded execution path.
 void setIdleQueue(junk.util.ds.PriorityQueue q)
          Set an idle queue for the thread to place itself into when it becomes idle.
 java.lang.String toString()
          A String representation of the JXThread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

module

private arch.module.major.JXMajorModule module
The reference to the module in which the task is to be done


task

private arch.task.JXTask task
The reference to the requested task for the module


error

private arch.message.error.JXError error
The error generated by this thread


isIdle

private boolean isIdle
Indicator for idle thread


isKill

private boolean isKill
Indicator for killing the thread


idleQ

private junk.util.ds.PriorityQueue idleQ
Reference to external idle queue.

Constructor Detail

JXThread

public JXThread(arch.module.major.JXMajorModule m,
                arch.task.JXTask t)
Create the default thread with a defined module and task.


JXThread

public JXThread(arch.module.major.JXMajorModule m,
                arch.task.JXTask t,
                junk.util.ds.PriorityQueue q)
Create the default thread with a defined module and task with an external idle queue. This constructor also provides an idle queue such that the thread when it becomes idle will automatically place itself into it to reduce the need for searches.

Method Detail

getError

public arch.message.error.JXError getError()

isIdle

public final boolean isIdle()
Tests if this thread is idle. A thread is idle if it has been started and is currently doing nothing.


isKill

public final boolean isKill()
Tests if this thread has been terminated.


kill

public final void kill()
To kill the thread. This method succeeds only if the thread is currently idle. If the thread is not idle but doing useful work, then it will only terminate after it has completed its previous assigned task.


reTask

public final boolean reTask(arch.module.major.JXMajorModule m,
                            arch.task.JXTask t)
Assign a new task to the thread. Used mainly for thread recycling.


run

public void run()
Encapsulates a request to a module to do a commit for a task into a separate threaded execution path.
Precondition:
module != null and task != null. Both the module and the task that is used to define the thread should not be null, else no useful work can be done and the thread will put itself into an idle state.
Postcondition:
The defined module will be committed to the task asigned to it such that the execution path is different from its creator.

Specified by:
run in interface java.lang.Runnable

setIdleQueue

public void setIdleQueue(junk.util.ds.PriorityQueue q)
Set an idle queue for the thread to place itself into when it becomes idle. The queue can be set anytime even if the thread was not created with a specific queue from the beginning.


toString

public java.lang.String toString()
A String representation of the JXThread. The exact details of the representation are unspecified and subject to change, but the following maybe regarded as typical: JXThread@1a3c5.