source: trunk/gcc/libjava/java/lang/Thread.java@ 2446

Last change on this file since 2446 was 1392, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.4 KB
Line 
1// Thread.java - Thread class.
2
3/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
4
5 This file is part of libgcj.
6
7This software is copyrighted work licensed under the terms of the
8Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9details. */
10
11package java.lang;
12
13import gnu.gcj.RawData;
14
15/**
16 * @author Tom Tromey <[email protected]>
17 * @date August 24, 1998
18 */
19
20/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
21 * "The Java Language Specification", ISBN 0-201-63451-1
22 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
23 * Status: Believed complete to version 1.3, with caveats. We do not
24 * implement the deprecated (and dangerous) stop, suspend, and resume
25 * methods. Security implementation is not complete.
26 */
27
28public class Thread implements Runnable
29{
30 public final static int MAX_PRIORITY = 10;
31 public final static int MIN_PRIORITY = 1;
32 public final static int NORM_PRIORITY = 5;
33
34 public static int activeCount ()
35 {
36 return currentThread().getThreadGroup().activeCount();
37 }
38
39 public final void checkAccess ()
40 {
41 SecurityManager s = System.getSecurityManager();
42 if (s != null)
43 s.checkAccess(this);
44 }
45
46 public native int countStackFrames ();
47 public static native Thread currentThread ();
48 public native void destroy ();
49
50 public static void dumpStack ()
51 {
52 (new Exception ("Stack trace")).printStackTrace ();
53 }
54
55 public static int enumerate (Thread[] threads)
56 {
57 return currentThread().group.enumerate(threads);
58 }
59
60 public final String getName ()
61 {
62 return name;
63 }
64
65 public final int getPriority ()
66 {
67 return priority;
68 }
69
70 public final ThreadGroup getThreadGroup ()
71 {
72 return group;
73 }
74
75 public native void interrupt ();
76
77 public static boolean interrupted ()
78 {
79 return currentThread().isInterrupted (true);
80 }
81
82 // Check the threads interrupted status. Note that this does not clear the
83 // thread's interrupted status (per JDK 1.2 online API documentation).
84 public boolean isInterrupted ()
85 {
86 return interrupt_flag;
87 }
88
89 public final boolean isAlive ()
90 {
91 return alive_flag;
92 }
93
94 public final boolean isDaemon ()
95 {
96 return daemon_flag;
97 }
98
99 public final void join () throws InterruptedException
100 {
101 join (0, 0);
102 }
103
104 public final void join (long timeout) throws InterruptedException
105 {
106 join (timeout, 0);
107 }
108
109 public final native void join (long timeout, int nanos)