ThreadState.java revision 13260:89668ec9523d
1/*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24package sun.jvm.hotspot.runtime;
25
26/** This is a type-safe enum mirroring the ThreadState enum in
27 osThread.hpp. The conversion between the underlying ints
28 and these values is done in OSThread. */
29
30public class ThreadState {
31
32    private String printVal;
33
34    /** Memory has been allocated but not initialized */
35    public static final ThreadState ALLOCATED = new ThreadState("allocated");
36    /** The thread has been initialized but yet started */
37    public static final ThreadState INITIALIZED = new ThreadState("initialized");
38    /** Has been started and is runnable, but not necessarily running */
39    public static final ThreadState RUNNABLE = new ThreadState("runnable");
40    /** Waiting on a contended monitor lock */
41    public static final ThreadState MONITOR_WAIT = new ThreadState("waiting for monitor entry");
42    /** Waiting on a condition variable */
43    public static final ThreadState CONDVAR_WAIT = new ThreadState("waiting on condition");
44    /** Waiting on an Object.wait() call */
45    public static final ThreadState OBJECT_WAIT = new ThreadState("in Object.wait()");
46    /** Suspended at breakpoint */
47    public static final ThreadState BREAKPOINTED = new ThreadState("at breakpoint");
48    /** Thread.sleep() */
49    public static final ThreadState SLEEPING = new ThreadState("sleeping");
50    /** All done, but not reclaimed yet */
51    public static final ThreadState ZOMBIE = new ThreadState("zombie");
52
53    private ThreadState(String printVal){
54        this.printVal = printVal;
55    }
56
57    public String getPrintVal() {
58        return printVal;
59    }
60}
61