KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > jpf > jvm > ThreadData


1 //
2
// Copyright (C) 2005 United States Government as represented by the
3
// Administrator of the National Aeronautics and Space Administration
4
// (NASA). All Rights Reserved.
5
//
6
// This software is distributed under the NASA Open Source Agreement
7
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
8
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
9
// directory tree for the complete NOSA document.
10
//
11
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18
//
19
package gov.nasa.jpf.jvm;
20
21 import gov.nasa.jpf.util.HashData;
22
23
24 /**
25  * this is the mutable Thread data we have to keep track of
26  */

27 class ThreadData {
28   /**
29    * Current state of the thread.
30    */

31   int status;
32
33   /** the scheduler priority of this thread */
34   int priority = java.lang.Thread.NORM_PRIORITY;
35
36   /**
37    * the name of this thread
38    * (only temporarily unset, between NEW and INVOKESPECIAL)
39    */

40   String JavaDoc name = "";
41
42   /** is this a daemon thread */
43   boolean isDaemon;
44
45   /**
46    * Class associated with the thread.
47    */

48   ClassInfo ci;
49
50   /**
51    * The object reference that is the thread.
52    */

53   int objref;
54
55   /**
56    * The object reference of the target object (if any).
57    */

58   int target = -1;
59
60   /**
61    * The lock counter when the object got into a wait.
62    */

63   int lockCount;
64
65
66   public Object JavaDoc clone () {
67     ThreadData t = new ThreadData();
68
69     t.status = status;
70     t.ci = ci;
71     t.objref = objref;
72     t.target = target;
73     t.lockCount = lockCount;
74
75     t.priority = priority;
76     t.name = name;
77     t.isDaemon = isDaemon;
78
79     return t;
80   }
81
82   public boolean equals (Object JavaDoc o) {
83     if ((o == null) || !(o instanceof ThreadData)) {
84       return false;
85     }
86
87     ThreadData t = (ThreadData) o;
88     
89     return ((status == t.status) && (ci == t.ci) && (objref == t.objref) &&
90            (target == t.target) && (priority == t.priority) &&
91            (isDaemon == t.isDaemon) && (lockCount == t.lockCount) &&
92            (name.equals(t.name)));
93   }
94
95   public void hash (HashData hd) {
96     hd.add(status);
97     hd.add(objref);
98     hd.add(target);
99     hd.add(lockCount);
100     hd.add(priority);
101     hd.add(isDaemon);
102     hd.add(name);
103
104     Boolean JavaDoc bo;
105   }
106
107   public int hashCode () {
108     HashData hd = new HashData();
109
110     hash(hd);
111
112     return hd.getValue();
113   }
114
115   public String JavaDoc toString () {
116     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
117
118     sb.append("ThreadData(");
119     sb.append("status=");
120     sb.append(status);
121     sb.append(",ci=");
122
123     if (ci == null) {
124       sb.append("null");
125     } else {
126       sb.append(ci.getName());
127     }
128
129     sb.append(",objref=");
130     sb.append(objref);
131     sb.append(",target=");
132     sb.append(target);
133     sb.append(",priority=");
134     sb.append(priority);
135     sb.append(",name=");
136     sb.append(name);
137     sb.append(",lockCount=");
138     sb.append(lockCount);
139     sb.append(')');
140
141     return sb.toString();
142   }
143 }
144
Popular Tags