1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.interpreter;
11
12 /***
13 * A InterpretationThread <br>
14 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
15 * University of Technology </a>, the Netherlands. <br>
16 * See for project information <a
17 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
18 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
19 * License (GPL) </a>, no warranty <br>
20 *
21 * @version 1.0 Feb 6, 2004 <br>
22 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
23 * Jacobs </a>
24 */
25 public final class InterpretationThread extends Thread
26 {
27 /*** the target of this interpretation */
28 private Runnable target = null;
29
30 /***
31 * constructs a new InterpretationThread
32 *
33 * @param target the target.
34 */
35 public InterpretationThread(final Runnable target)
36 {
37 super();
38 this.target = target;
39 }
40
41 /***
42 * constructs a new InterpretationThread
43 *
44 * @param target the target.
45 * @param name the name of the thread
46 */
47 public InterpretationThread(final Runnable target, final String name)
48 {
49 super(name);
50 this.target = target;
51 }
52
53 /***
54 * constructs a new InterpretationThread
55 *
56 * @param group the threadGroup
57 * @param target the target.
58 */
59 public InterpretationThread(final ThreadGroup group, final Runnable target)
60 {
61 super(group, target);
62 this.target = target;
63 }
64
65 /***
66 * constructs a new InterpretationThread
67 *
68 * @param group the threadGroup
69 * @param target the target.
70 * @param name the name of the thread
71 */
72 public InterpretationThread(final ThreadGroup group, final Runnable target,
73 final String name)
74 {
75 super(group, target, name);
76 this.target = target;
77 }
78
79 /***
80 * @see java.lang.Runnable#run()
81 */
82 public void run()
83 {
84 try
85 {
86 Interpreter.invoke(this.target, this.target.getClass()
87 .getDeclaredMethod("run", null), null);
88 } catch (Exception exception)
89 {
90 exception.printStackTrace();
91 }
92 }
93 }