01: /*
02: * MCS Media Computer Software Copyright (c) 2006 by MCS
03: * -------------------------------------- Created on 11.04.2006 by w.klaas
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package de.mcs.utils;
18:
19: /**
20: * This is the working thread class needed for the threadedpool.
21: *
22: * @author w.klaas
23: *
24: */
25: public class WorkingThread extends Thread {
26:
27: /** my runnabe interface. */
28: private Runnable run = null;
29:
30: /** just nothing to do. */
31: private boolean free = true;
32:
33: /**
34: * setting a new runnable.
35: *
36: * @param runit
37: * the runnable.
38: */
39: public final void setRunnable(final Runnable runit) {
40: this .run = runit;
41: }
42:
43: /**
44: * @see java.lang.Thread#run()
45: */
46: @Override
47: public final void run() {
48: setBusy();
49: if (null != run) {
50: run.run();
51: }
52: setFree();
53: }
54:
55: /**
56: * @return Returns the free.
57: */
58: public final boolean isFree() {
59: return free;
60: }
61:
62: /**
63: * setting the free state.
64: */
65: public final void setFree() {
66: this .free = true;
67: }
68:
69: /**
70: * setting this thread to busy.
71: */
72: public final void setBusy() {
73: this .free = false;
74: }
75:
76: }
|