1 package com.explosion.utilities.process.threads;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 /***
24 * Title: Controllable Interface Description: This interface defines a set of
25 * methods which allow a Runnable Object to be effectively controlled by another
26 * object
27 *
28 * @author Stephen Cowx
29 * @version
30 */
31
32 public interface ProcessThread extends Runnable
33 {
34
35
36 public static final int NORM_PRIORITY = Thread.NORM_PRIORITY;
37
38 public static final int MAX_PRIORITY = Thread.MAX_PRIORITY;
39
40 public static final int MIN_PRIORITY = Thread.MIN_PRIORITY;
41
42
43 public final static int THREAD_NOT_YET_STARTED = -1;
44
45 public final static int THREAD_COMPLETED = 0;
46
47 public final static int THREAD_STARTED = 1;
48
49 public final static int THREAD_SUSPENDED = 2;
50
51 public final static int THREAD_STOPPED = 3;
52
53 /***
54 * For an explanation on implementing safely stoppable and suspendable
55 * threads please see
56 *
57 * @see http://java.sun.com/products/jdk/1.2/docs/guide/misc/threadPrimitiveDeprecation.html
58 */
59 public void run();
60
61 /***
62 * Stop the job
63 */
64 public void stop() throws InterruptedException;
65
66 /***
67 * Kills the job
68 */
69 public void kill();
70
71 /***
72 * Returns whether or not the job was killed
73 */
74 public boolean wasKilled();
75
76 /***
77 * Starts the job.
78 */
79 public void start();
80
81 /***
82 * Temporarily suspends the job exactly where it is
83 */
84 public void suspend();
85
86 /***
87 * Restarts the job.
88 */
89 public void resume();
90
91 /***
92 * This method allows the user to set the Thread priority of this
93 * controllable object. Priorities are:
94 */
95 public void setPriority(int priority);
96
97 /***
98 * This method allows the user to set the interval between each thread loop.
99 * Default is 10 (0.001 seconds);
100 */
101 public void setInterval(int interval);
102
103 /***
104 * Set the Process for this UnitisedProcess
105 */
106 public void setProcess(Process process);
107
108 /***
109 * Set the process for this Process
110 */
111 public Process getProcess();
112
113 /***
114 * This method returns the actual thread object upon which this Runnable
115 * object is operating.
116 */
117 public Thread getRunThread();
118
119 /***
120 * This method returns status of the thread
121 */
122 public int getStatus();
123
124 /***
125 * Performs suspend logic if the thread has been suspended
126 */
127 public void checkSuspended();
128
129 }