1 /* Thread -- an independent thread of executable code
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 Free Software Foundation
5 This file is part of GNU Classpath.
7 GNU Classpath is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Classpath is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Classpath; see the file COPYING. If not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 Linking this library statically or dynamically with other modules is
23 making a combined work based on this library. Thus, the terms and
24 conditions of the GNU General Public License cover the whole
27 As a special exception, the copyright holders of this library give you
28 permission to link this library with independent modules to produce an
29 executable, regardless of the license terms of these independent
30 modules, and to copy and distribute the resulting executable under
31 terms of your choice, provided that you also meet, for each linked
32 independent module, the terms and conditions of the license of that
33 module. An independent module is a module which is not derived from
34 or based on this library. If you modify this library, you may extend
35 this exception to your version of the library, but you are not
36 obligated to do so. If you do not wish to do so, delete this
37 exception statement from your version. */
41 import gnu.gcj.RawData;
43 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
44 * "The Java Language Specification", ISBN 0-201-63451-1
45 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
46 * Status: Believed complete to version 1.4, with caveats. We do not
47 * implement the deprecated (and dangerous) stop, suspend, and resume
48 * methods. Security implementation is not complete.
52 * Thread represents a single thread of execution in the VM. When an
53 * application VM starts up, it creates a non-daemon Thread which calls the
54 * main() method of a particular class. There may be other Threads running,
55 * such as the garbage collection thread.
57 * <p>Threads have names to identify them. These names are not necessarily
58 * unique. Every Thread has a priority, as well, which tells the VM which
59 * Threads should get more running time. New threads inherit the priority
60 * and daemon status of the parent thread, by default.
62 * <p>There are two methods of creating a Thread: you may subclass Thread and
63 * implement the <code>run()</code> method, at which point you may start the
64 * Thread by calling its <code>start()</code> method, or you may implement
65 * <code>Runnable</code> in the class you want to use and then call new
66 * <code>Thread(your_obj).start()</code>.
68 * <p>The virtual machine runs until all non-daemon threads have died (either
69 * by returning from the run() method as invoked by start(), or by throwing
70 * an uncaught exception); or until <code>System.exit</code> is called with
71 * adequate permissions.
73 * <p>It is unclear at what point a Thread should be added to a ThreadGroup,
74 * and at what point it should be removed. Should it be inserted when it
75 * starts, or when it is created? Should it be removed when it is suspended
76 * or interrupted? The only thing that is clear is that the Thread should be
77 * removed when it is stopped.
81 * @author Eric Blake <ebb9@email.byu.edu>
83 * @see Runtime#exit(int)
88 * @status updated to 1.4
90 public class Thread implements Runnable
92 /** The maximum priority for a Thread. */
93 public final static int MAX_PRIORITY = 10;
95 /** The minimum priority for a Thread. */
96 public final static int MIN_PRIORITY = 1;
98 /** The priority a Thread gets by default. */
99 public final static int NORM_PRIORITY = 5;
102 * Get the number of active threads in the current Thread's ThreadGroup.
103 * This implementation calls
104 * <code>currentThread().getThreadGroup().activeCount()</code>.
106 * @return the number of active threads in the current ThreadGroup
107 * @see ThreadGroup#activeCount()
109 public static int activeCount ()
111 return currentThread().getThreadGroup().activeCount();
115 * Check whether the current Thread is allowed to modify this Thread. This
116 * passes the check on to <code>SecurityManager.checkAccess(this)</code>.
118 * @throws SecurityException if the current Thread cannot modify this Thread
119 * @see SecurityManager#checkAccess(Thread)
121 public final void checkAccess ()
123 SecurityManager s = System.getSecurityManager();
129 * Count the number of stack frames in this Thread. The Thread in question
130 * must be suspended when this occurs.
132 * @return the number of stack frames in this Thread
133 * @throws IllegalThreadStateException if this Thread is not suspended
134 * @deprecated pointless, since suspend is deprecated
136 public native int countStackFrames ();
139 * Get the currently executing Thread.
141 * @return the currently executing Thread
143 public static native Thread currentThread ();
146 * Originally intended to destroy this thread, this method was never
147 * implemented by Sun, and is hence a no-op.
149 public native void destroy ();
152 * Print a stack trace of the current thread to stderr using the same
153 * format as Throwable's printStackTrace() method.
155 * @see Throwable#printStackTrace()
157 public static void dumpStack ()
159 (new Exception ("Stack trace")).printStackTrace ();
163 * Copy every active thread in the current Thread's ThreadGroup into the
164 * array. Extra threads are silently ignored. This implementation calls
165 * <code>getThreadGroup().enumerate(array)</code>, which may have a
166 * security check, <code>checkAccess(group)</code>.
168 * @param array the array to place the Threads into
169 * @return the number of Threads placed into the array
170 * @throws NullPointerException if array is null
171 * @throws SecurityException if you cannot access the ThreadGroup
172 * @see ThreadGroup#enumerate(Thread[])
173 * @see #activeCount()
174 * @see SecurityManager#checkAccess(ThreadGroup)
176 public static int enumerate (Thread[] threads)
178 return currentThread().group.enumerate(threads);
182 * Get this Thread's name.
184 * @return this Thread's name
186 public final String getName ()
192 * Get this Thread's priority.
194 * @return the Thread's priority
196 public final int getPriority ()
202 * Get the ThreadGroup this Thread belongs to. If the thread has died, this
205 * @return this Thread's ThreadGroup
207 public final ThreadGroup getThreadGroup ()
213 * Return true if this Thread holds the object's lock, false otherwise.
215 * @param obj the object to test lock ownership on.
216 * @throws NullPointerException if obj is null.
219 public static native boolean holdsLock (Object obj);
222 * Interrupt this Thread. First, there is a security check,
223 * <code>checkAccess</code>. Then, depending on the current state of the
224 * thread, various actions take place:
226 * <p>If the thread is waiting because of {@link #wait()},
227 * {@link #sleep(long)}, or {@link #join()}, its <i>interrupt status</i>
228 * will be cleared, and an InterruptedException will be thrown. Notice that
229 * this case is only possible if an external thread called interrupt().
231 * <p>If the thread is blocked in an interruptible I/O operation, in
232 * {@link java.nio.channels.InterruptibleChannel}, the <i>interrupt
233 * status</i> will be set, and ClosedByInterruptException will be thrown.
235 * <p>If the thread is blocked on a {@link java.nio.channels.Selector}, the
236 * <i>interrupt status</i> will be set, and the selection will return, with
237 * a possible non-zero value, as though by the wakeup() method.
239 * <p>Otherwise, the interrupt status will be set.
241 * @throws SecurityException if you cannot modify this Thread
243 public native void interrupt ();
246 * Determine whether the current Thread has been interrupted, and clear
247 * the <i>interrupted status</i> in the process.
249 * @return whether the current Thread has been interrupted
250 * @see #isInterrupted()
252 public static boolean interrupted ()
254 return currentThread().isInterrupted (true);
258 * Determine whether the given Thread has been interrupted, but leave
259 * the <i>interrupted status</i> alone in the process.
261 * @return whether the current Thread has been interrupted
262 * @see #interrupted()
264 public boolean isInterrupted ()
266 return interrupt_flag;
270 * Determine whether this Thread is alive. A thread which is alive has
271 * started and not yet died.
273 * @return whether this Thread is alive
275 public final boolean isAlive ()
281 * Tell whether this is a daemon Thread or not.
283 * @return whether this is a daemon Thread or not
284 * @see #setDaemon(boolean)
286 public final boolean isDaemon ()
292 * Wait forever for the Thread in question to die.
294 * @throws InterruptedException if the Thread is interrupted; it's
295 * <i>interrupted status</i> will be cleared
297 public final void join () throws InterruptedException
303 * Wait the specified amount of time for the Thread in question to die.
305 * @param ms the number of milliseconds to wait, or 0 for forever
306 * @throws InterruptedException if the Thread is interrupted; it's
307 * <i>interrupted status</i> will be cleared
309 public final void join (long timeout) throws InterruptedException
315 * Wait the specified amount of time for the Thread in question to die.
317 * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
318 * not offer that fine a grain of timing resolution. Besides, there is
319 * no guarantee that this thread can start up immediately when time expires,
320 * because some other thread may be active. So don't expect real-time
323 * @param ms the number of milliseconds to wait, or 0 for forever
324 * @param ns the number of extra nanoseconds to sleep (0-999999)
325 * @throws InterruptedException if the Thread is interrupted; it's
326 * <i>interrupted status</i> will be cleared
327 * @throws IllegalArgumentException if ns is invalid
328 * @XXX A ThreadListener would be nice, to make this efficient.
330 public final native void join (long timeout, int nanos)
331 throws InterruptedException;
334 * Resume a suspended thread.
337 * @deprecated pointless, since suspend is deprecated
339 public final native void resume ();
341 private final native void finish_ ();
344 * Determine whether the given Thread has been interrupted, but leave
345 * the <i>interrupted status</i> alone in the process.
347 * @return whether the current Thread has been interrupted
348 * @see #interrupted()
350 private boolean isInterrupted (boolean clear_flag)
352 boolean r = interrupt_flag;
355 // Only clear the flag if we saw it as set. Otherwise this could
356 // potentially cause us to miss an interrupt in a race condition,
357 // because this method is not synchronized.
358 interrupt_flag = false;
364 * The method of Thread that will be run if there is no Runnable object
365 * associated with the Thread. Thread's implementation does nothing at all.
368 * @see #Thread(ThreadGroup, Runnable, String)
372 if (runnable != null)
377 * Set the daemon status of this Thread. If this is a daemon Thread, then
378 * the VM may exit even if it is still running. This may only be called
379 * before the Thread starts running. There may be a security check,
380 * <code>checkAccess</code>.
382 * @param daemon whether this should be a daemon thread or not
383 * @throws SecurityException if you cannot modify this Thread
384 * @throws IllegalThreadStateException if the Thread is active
386 * @see #checkAccess()
388 public final void setDaemon (boolean status)
392 throw new IllegalThreadStateException ();
393 daemon_flag = status;
397 * Returns the context classloader of this Thread. The context
398 * classloader can be used by code that want to load classes depending
399 * on the current thread. Normally classes are loaded depending on
400 * the classloader of the current class. There may be a security check
401 * for <code>RuntimePermission("getClassLoader")</code> if the caller's
402 * class loader is not null or an ancestor of this thread's context class
405 * @return the context class loader
406 * @throws SecurityException when permission is denied
407 * @see setContextClassLoader(ClassLoader)
410 public synchronized ClassLoader getContextClassLoader()
412 if (context_class_loader == null)
413 context_class_loader = ClassLoader.getSystemClassLoader ();
415 SecurityManager s = System.getSecurityManager();
416 // FIXME: we can't currently find the caller's class loader.
417 ClassLoader callers = null;
418 if (s != null && callers != null)
420 // See if the caller's class loader is the same as or an
421 // ancestor of this thread's class loader.
422 while (callers != null && callers != context_class_loader)
424 // FIXME: should use some internal version of getParent
425 // that avoids security checks.
426 callers = callers.getParent ();
429 if (callers != context_class_loader)
430 s.checkPermission (new RuntimePermission ("getClassLoader"));
433 return context_class_loader;
437 * Returns the context classloader of this Thread. The context
438 * classloader can be used by code that want to load classes depending
439 * on the current thread. Normally classes are loaded depending on
440 * the classloader of the current class. There may be a security check
441 * for <code>RuntimePermission("getClassLoader")</code> if the caller's
442 * class loader is not null or an ancestor of this thread's context class
445 * @return the context class loader
446 * @throws SecurityException when permission is denied
447 * @see setContextClassLoader(ClassLoader)
450 public synchronized void setContextClassLoader(ClassLoader cl)
452 SecurityManager s = System.getSecurityManager ();
454 s.checkPermission (new RuntimePermission ("setContextClassLoader"));
455 context_class_loader = cl;
459 * Set this Thread's name. There may be a security check,
460 * <code>checkAccess</code>.
462 * @param name the new name for this Thread
463 * @throws NullPointerException if name is null
464 * @throws SecurityException if you cannot modify this Thread
466 public final void setName (String n)
469 // The Class Libraries book says ``threadName cannot be null''. I
470 // take this to mean NullPointerException.
472 throw new NullPointerException ();
477 * Set this Thread's priority. There may be a security check,
478 * <code>checkAccess</code>, then the priority is set to the smaller of
479 * priority and the ThreadGroup maximum priority.
481 * @param priority the new priority for this Thread
482 * @throws IllegalArgumentException if priority exceeds MIN_PRIORITY or
484 * @throws SecurityException if you cannot modify this Thread
485 * @see #getPriority()
486 * @see #checkAccess()
487 * @see ThreadGroup#getMaxPriority()
491 public final native void setPriority (int newPriority);
494 * Suspend the current Thread's execution for the specified amount of
495 * time. The Thread will not lose any locks it has during this time. There
496 * are no guarantees which thread will be next to run, but most VMs will
497 * choose the highest priority thread that has been waiting longest.
499 * @param ms the number of milliseconds to sleep, or 0 for forever
500 * @throws InterruptedException if the Thread is interrupted; it's
501 * <i>interrupted status</i> will be cleared
505 public static void sleep (long timeout) throws InterruptedException
511 * Suspend the current Thread's execution for the specified amount of
512 * time. The Thread will not lose any locks it has during this time. There
513 * are no guarantees which thread will be next to run, but most VMs will
514 * choose the highest priority thread that has been waiting longest.
516 * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
517 * not offer that fine a grain of timing resolution. Besides, there is
518 * no guarantee that this thread can start up immediately when time expires,
519 * because some other thread may be active. So don't expect real-time
522 * @param ms the number of milliseconds to sleep, or 0 for forever
523 * @param ns the number of extra nanoseconds to sleep (0-999999)
524 * @throws InterruptedException if the Thread is interrupted; it's
525 * <i>interrupted status</i> will be cleared
526 * @throws IllegalArgumentException if ns is invalid
528 * @see #wait(long, int)
530 public static native void sleep (long timeout, int nanos)
531 throws InterruptedException;
534 * Start this Thread, calling the run() method of the Runnable this Thread
535 * was created with, or else the run() method of the Thread itself. This
536 * is the only way to start a new thread; calling run by yourself will just
537 * stay in the same thread. The virtual machine will remove the thread from
538 * its thread group when the run() method completes.
540 * @throws IllegalThreadStateException if the thread has already started
543 public native void start ();
546 * Cause this Thread to stop abnormally because of the throw of a ThreadDeath
547 * error. If you stop a Thread that has not yet started, it will stop
548 * immediately when it is actually started.
550 * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
551 * leave data in bad states. Hence, there is a security check:
552 * <code>checkAccess(this)</code>, plus another one if the current thread
553 * is not this: <code>RuntimePermission("stopThread")</code>. If you must
554 * catch a ThreadDeath, be sure to rethrow it after you have cleaned up.
555 * ThreadDeath is the only exception which does not print a stack trace when
558 * @throws SecurityException if you cannot stop the Thread
560 * @see #checkAccess()
563 * @see ThreadGroup#uncaughtException(Thread, Throwable)
564 * @see SecurityManager#checkAccess(Thread)
565 * @see SecurityManager#checkPermission(Permission)
566 * @deprecated unsafe operation, try not to use
568 public final void stop ()
570 // Argument doesn't matter, because this is no longer
576 * Cause this Thread to stop abnormally and throw the specified exception.
577 * If you stop a Thread that has not yet started, it will stop immediately
578 * when it is actually started. <b>WARNING</b>This bypasses Java security,
579 * and can throw a checked exception which the call stack is unprepared to
580 * handle. Do not abuse this power.
582 * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
583 * leave data in bad states. Hence, there is a security check:
584 * <code>checkAccess(this)</code>, plus another one if the current thread
585 * is not this: <code>RuntimePermission("stopThread")</code>. If you must
586 * catch a ThreadDeath, be sure to rethrow it after you have cleaned up.
587 * ThreadDeath is the only exception which does not print a stack trace when
590 * @param t the Throwable to throw when the Thread dies
591 * @throws SecurityException if you cannot stop the Thread
592 * @throws NullPointerException in the calling thread, if t is null
594 * @see #checkAccess()
597 * @see ThreadGroup#uncaughtException(Thread, Throwable)
598 * @see SecurityManager#checkAccess(Thread)
599 * @see SecurityManager#checkPermission(Permission)
600 * @deprecated unsafe operation, try not to use
602 public final native void stop (Throwable e);
605 * Suspend this Thread. It will not come back, ever, unless it is resumed.
607 * <p>This is inherently unsafe, as the suspended thread still holds locks,
608 * and can potentially deadlock your program. Hence, there is a security
609 * check: <code>checkAccess</code>.
611 * @throws SecurityException if you cannot suspend the Thread
612 * @see #checkAccess()
614 * @deprecated unsafe operation, try not to use
616 public final native void suspend ();
618 private final native void initialize_native ();
620 private final native static String gen_name ();
623 * Allocate a new Thread object, with the specified ThreadGroup and name, and
624 * using the specified Runnable object's <code>run()</code> method to
625 * execute. If the Runnable object is null, <code>this</code> (which is
626 * a Runnable) is used instead.
628 * <p>If the ThreadGroup is null, the security manager is checked. If a
629 * manager exists and returns a non-null object for
630 * <code>getThreadGroup</code>, that group is used; otherwise the group
631 * of the creating thread is used. Note that the security manager calls
632 * <code>checkAccess</code> if the ThreadGroup is not null.
634 * <p>The new Thread will inherit its creator's priority and daemon status.
635 * These can be changed with <code>setPriority</code> and
636 * <code>setDaemon</code>.
638 * @param group the group to put the Thread into
639 * @param target the Runnable object to execute
640 * @param name the name for the Thread
641 * @throws NullPointerException if name is null
642 * @throws SecurityException if this thread cannot access <code>group</code>
643 * @throws IllegalThreadStateException if group is destroyed
644 * @see Runnable#run()
646 * @see #setDaemon(boolean)
647 * @see #setPriority(int)
648 * @see SecurityManager#checkAccess(ThreadGroup)
649 * @see ThreadGroup#checkAccess()
651 public Thread (ThreadGroup g, Runnable r, String n)
653 this (currentThread (), g, r, n);
657 * Allocate a new Thread object, as if by
658 * <code>Thread(group, null, name)</code>, and give it the specified stack
659 * size, in bytes. The stack size is <b>highly platform independent</b>,
660 * and the virtual machine is free to round up or down, or ignore it
661 * completely. A higher value might let you go longer before a
662 * <code>StackOverflowError</code>, while a lower value might let you go
663 * longer before an <code>OutOfMemoryError</code>. Or, it may do absolutely
664 * nothing! So be careful, and expect to need to tune this value if your
665 * virtual machine even supports it.
667 * @param group the group to put the Thread into
668 * @param target the Runnable object to execute
669 * @param name the name for the Thread
670 * @param size the stack size, in bytes; 0 to be ignored
671 * @throws NullPointerException if name is null
672 * @throws SecurityException if this thread cannot access <code>group</code>
673 * @throws IllegalThreadStateException if group is destroyed
676 public Thread (ThreadGroup g, Runnable r, String n, long size)
678 // Just ignore stackSize for now.
679 this (currentThread (), g, r, n);
682 private Thread (Thread current, ThreadGroup g, Runnable r, String n)
684 // The Class Libraries book says ``threadName cannot be null''. I
685 // take this to mean NullPointerException.
687 throw new NullPointerException ();
691 // If CURRENT is null, then we are bootstrapping the first thread.
692 // Use ThreadGroup.root, the main threadgroup.
694 group = ThreadGroup.root;
696 group = current.getThreadGroup();
702 interrupt_flag = false;
704 startable_flag = true;
710 daemon_flag = current.isDaemon();
711 int gmax = group.getMaxPriority();
712 int pri = current.getPriority();
713 priority = (gmax < pri ? gmax : pri);
714 context_class_loader = current.context_class_loader;
715 InheritableThreadLocal.newChildThread(this);
720 priority = NORM_PRIORITY;
724 group.addThread(this);
727 initialize_native ();
731 * Allocates a new <code>Thread</code> object. This constructor has
732 * the same effect as <code>Thread(null, null,</code>
733 * <i>gname</i><code>)</code>, where <b><i>gname</i></b> is
734 * a newly generated name. Automatically generated names are of the
735 * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
737 * Threads created this way must have overridden their
738 * <code>run()</code> method to actually do anything. An example
739 * illustrating this method being used follows:
740 * <p><blockquote><pre>
741 * import java.lang.*;
743 * class plain01 implements Runnable {
748 * plain01(String s) {
751 * public void run() {
753 * System.out.println("A new thread created");
755 * System.out.println("A new thread with name " + name +
759 * class threadtest01 {
760 * public static void main(String args[] ) {
763 * <b>Thread t1 = new Thread();</b>
765 * System.out.println("new Thread() succeed");
767 * System.out.println("new Thread() failed");
772 * </pre></blockquote>
774 * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
775 * java.lang.Runnable, java.lang.String)
779 this (null, null, gen_name ());
783 * Allocates a new <code>Thread</code> object. This constructor has
784 * the same effect as <code>Thread(null, target,</code>
785 * <i>gname</i><code>)</code>, where <i>gname</i> is
786 * a newly generated name. Automatically generated names are of the
787 * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
789 * @param target the object whose <code>run</code> method is called.
790 * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
791 * java.lang.Runnable, java.lang.String)
793 public Thread (Runnable r)
795 this (null, r, gen_name ());
799 * Allocates a new <code>Thread</code> object. This constructor has
800 * the same effect as <code>Thread(null, null, name)</code>.
802 * @param name the name of the new thread.
803 * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
804 * java.lang.Runnable, java.lang.String)
806 public Thread (String n)
808 this (null, null, n);
812 * Allocates a new <code>Thread</code> object. This constructor has
813 * the same effect as <code>Thread(group, target,</code>
814 * <i>gname</i><code>)</code>, where <i>gname</i> is
815 * a newly generated name. Automatically generated names are of the
816 * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
818 * @param group the thread group.
819 * @param target the object whose <code>run</code> method is called.
820 * @exception SecurityException if the current thread cannot create a
821 * thread in the specified thread group.
822 * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
823 * java.lang.Runnable, java.lang.String)
825 public Thread (ThreadGroup g, Runnable r)
827 this (g, r, gen_name ());
831 * Allocates a new <code>Thread</code> object. This constructor has
832 * the same effect as <code>Thread(group, null, name)</code>
834 * @param group the thread group.
835 * @param name the name of the new thread.
836 * @exception SecurityException if the current thread cannot create a
837 * thread in the specified thread group.
838 * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
839 * java.lang.Runnable, java.lang.String)
841 public Thread (ThreadGroup g, String n)
847 * Allocates a new <code>Thread</code> object. This constructor has
848 * the same effect as <code>Thread(null, target, name)</code>.
850 * @param target the object whose <code>run</code> method is called.
851 * @param name the name of the new thread.
852 * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
853 * java.lang.Runnable, java.lang.String)
855 public Thread (Runnable r, String n)
861 * Returns a string representation of this thread, including the
862 * thread's name, priority, and thread group.
864 * @return a string representation of this thread.
866 public String toString ()
868 return "Thread[" + name + "," + priority + "," +
869 (group == null ? "" : group.getName()) + "]";
873 * Causes the currently executing thread object to temporarily pause
874 * and allow other threads to execute.
876 public static native void yield ();
881 private Runnable runnable;
882 private int priority;
883 private boolean daemon_flag;
884 boolean interrupt_flag;
885 private boolean alive_flag;
886 private boolean startable_flag;
887 private ClassLoader context_class_loader;
889 // This describes the top-most interpreter frame for this thread.
890 RawData interp_frame;
892 // Our native data - points to an instance of struct natThread.