2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package gov.nasa.jpf.vm;
20 import gov.nasa.jpf.util.HashData;
24 * this is the mutable Thread data we have to keep track of for storing/restoring states
26 public class ThreadData {
28 * Current state of the thread.
30 ThreadInfo.State state;
32 /** the scheduler priority of this thread */
36 * the name of this thread
37 * (only temporarily unset, between NEW and INVOKESPECIAL)
41 /** is this a daemon thread */
45 * The lock counter when the object got into a wait. This value
46 * is used to restore the object lock count once this thread
52 * The suspend count of the thread. See ThreadInfo.suspend() for a discussion
53 * of how faithful this is (it is an over approximation)
59 public ThreadData clone () {
60 ThreadData t = new ThreadData();
63 t.lockCount = lockCount;
64 t.suspendCount = suspendCount;
66 t.priority = priority;
68 t.isDaemon = isDaemon;
74 public boolean equals (Object o) {
75 if ((o == null) || !(o instanceof ThreadData)) {
79 ThreadData t = (ThreadData) o;
81 return ((state == t.state) &&
82 (priority == t.priority) &&
83 (isDaemon == t.isDaemon) &&
84 (lockCount == t.lockCount) &&
85 (suspendCount == t.suspendCount) &&
86 (name.equals(t.name)));
89 public void hash (HashData hd) {
99 public int hashCode () {
100 HashData hd = new HashData();
104 return hd.getValue();
108 public String toString () {
109 return ("ThreadData{" + getFieldValues() + '}');
112 public String getFieldValues () {
113 StringBuilder sb = new StringBuilder("name:");
116 sb.append(",status:");
117 sb.append(state.name());
118 sb.append(",priority:");
120 sb.append(",isDaemon:");
122 sb.append(",lockCount:");
123 sb.append(lockCount);
124 sb.append(",suspendCount:");
125 sb.append(suspendCount);
127 return sb.toString();
130 public ThreadInfo.State getState() { return state; }