Save This Page
Home » openjdk-7 » java » lang » [javadoc | source]
java.lang
final class: VMThread [javadoc | source]
java.lang.Object
   java.lang.VMThread
VM interface for Thread of executable code. Holds VM dependent state. It is deliberately package local and final and should only be accessed by the Thread class.

This is the GNU Classpath reference implementation, it should be adapted for a specific VM.

The following methods must be implemented:

All other methods may be implemented to make Thread handling more efficient or to implement some optional (and sometimes deprecated) behaviour. Default implementations are provided but it is highly recommended to optimize them for a specific VM.
Field Summary
volatile  Thread thread    The Thread object that this VM state belongs to. Used in currentThread() and start(). Note: when this thread dies, this reference is *not* cleared 
Method from java.lang.VMThread Summary:
countStackFrames,   create,   currentThread,   getName,   getPriority,   holdsLock,   interrupt,   interrupted,   isDaemon,   isInterrupted,   join,   nativeSetPriority,   nativeStop,   resume,   setName,   setPriority,   sleep,   start,   stop,   suspend,   yield
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.lang.VMThread Detail:
 native int countStackFrames()Deprecated! unsafe -  operation

    Returns the number of stack frames in this Thread. Will only be called when when a previous call to suspend() returned true.
 static  void create(Thread thread,
    long stacksize) 
    Creates a native Thread. This is called from the start method of Thread. The Thread is started.
 static native Thread currentThread()
    Return the Thread object associated with the currently executing thread.
 String getName() 
    Gets the name of the thread. Usually this is the name field of the associated Thread object, but some implementation might choose to return the name of the underlying platform thread.
 int getPriority() 
    Returns the priority. Usually this is the priority field from the associated Thread object, but some implementation might choose to return the priority of the underlying platform thread.
 static boolean holdsLock(Object obj) 
    Checks whether the current thread holds the monitor on a given object. This allows you to do assert Thread.holdsLock(obj).
 native  void interrupt()
    Interrupt this thread.
 static native boolean interrupted()
    Determine whether the current Thread has been interrupted, and clear the interrupted status in the process.
 boolean isDaemon() 
    Returns true if the thread is a daemon thread. Usually this is the daemon field from the associated Thread object, but some implementation might choose to return the daemon state of the underlying platform thread.
 native boolean isInterrupted()
    Determine whether this Thread has been interrupted, but leave the interrupted status alone in the process.
 synchronized  void join(long ms,
    int ns) throws InterruptedException 
    Wait the specified amount of time for the Thread in question to die.

    Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do not offer that fine a grain of timing resolution. Besides, there is no guarantee that this thread can start up immediately when time expires, because some other thread may be active. So don't expect real-time performance.

 native  void nativeSetPriority(int priority)
    Set the priority of the underlying platform thread.
 native  void nativeStop(Throwable t)
    Asynchronously throw the specified throwable in this Thread.
 native  void resume()
    Resume this Thread. If the thread is not suspended, this method does nothing.
  void setName(String name) 
    Set the name of the thread. Usually this sets the name field of the associated Thread object, but some implementations might choose to set the name of the underlying platform thread.
  void setPriority(int priority) 
    Set the thread priority field in the associated Thread object and calls the native method to set the priority of the underlying platform thread.
 static  void sleep(long ms,
    int ns) throws InterruptedException 
    Suspend the current Thread's execution for the specified amount of time. The Thread will not lose any locks it has during this time. There are no guarantees which thread will be next to run, but most VMs will choose the highest priority thread that has been waiting longest.

    Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do not offer that fine a grain of timing resolution. Besides, there is no guarantee that this thread can start up immediately when time expires, because some other thread may be active. So don't expect real-time performance.

 native  void start(long stacksize)
    Create a native thread on the underlying platform and start it executing on the run method of this object.
  void stop(Throwable t) 
Deprecated! unsafe - operation, try not to use

    Cause this Thread to stop abnormally and throw the specified exception. If you stop a Thread that has not yet started, the stop is ignored (contrary to what the JDK documentation says). WARNINGThis bypasses Java security, and can throw a checked exception which the call stack is unprepared to handle. Do not abuse this power.

    This is inherently unsafe, as it can interrupt synchronized blocks and leave data in bad states.

    NOTE stop() should take care not to stop a thread if it is executing code in this class.

 native  void suspend()
    Suspend this Thread. It will not come back, ever, unless it is resumed.
 static native  void yield()
    Yield to another thread. The Thread will not lose any locks it holds during this time. There are no guarantees which thread will be next to run, and it could even be this one, but most VMs will choose the highest priority thread that has been waiting longest.