Thread is a relatively close concept of a platform relationship. We can't see its specific implementation, you can only look at it.
Public Class Thread IMPLEMENTS Runnable
Public final static int min_priority = 1; public final static int Norm_Priority = 5; public final static int max_priority = 10; // The above three is the priority of the thread, the default is the same, the parent thread has the same priority PUBLIC Static Native Thread CurrentThread (); // Get the thread instance of the current running thread, Note that this is a static method public static native void yield (); // The current thread actively gives up the execution, so that other threads can be run, this is the Lei Feng spirit public static Native Void Sleep (Long Millis) THROWS InterruptedException; // The current thread sleeps yourself for a while, after this time it returns to the executable state, sometimes in order to wait for someone else to sleep, I will sleep, how long this is sleeping. Time is more difficult to determine public static void sleep (long millis, int nanos) throws interruptedException // This method is a bit redundant, putting the back of the nanoseconds, the final effect or Sleep (Millis) and Sleep (Millis 1) .
Constructor PUBLIC Thread (); public thread (runnable target) // This is the most common constructor PUBLIC THREAD (THREADGROUP Group, Runnable Target) // is not very concerned about which thread group public thread (String name) // We seem I do not care about the thread name public thread (ThreadGroup group, String name) public thread (Runnable target, String name) public thread (ThreadGroup group, Runnable target, String name) public thread (ThreadGroup group, Runnable target, String name, long stackSize) Public synchronized native void start (); // Running the thread with the start method, do not know how to implement it, but call the RUN method public void run () {if (target! = null) {target.run ();} It can be seen that if there is no Target parameter, this thread does not do anything.
// The following methods are no longer available, I am not very clear, don't need to take this .public final void stop () public final synchronized void stop (throwable obj) public void suspend () Public Final Void Resume )
Public void interrupt () // interrupt this thread, this method does not know what to do in addition to the interrupt status bit.
public static boolean interrupted () {return currentThread () isInterrupted (true);.} // if interrupted, reset interrupt status public boolean isInterrupted () {return isInterrupted (false);} // if interrupted private native boolean isInterrupted (boolean ClearInterrupted); public void destroy () {throw new NoSuchMethodError ();} public final native boolean isAlive (); // if the thread is still alive, not dead but was born a public final void setPriority (int newPriority) public final void setName (String name) public final String getName () public final ThreadGroup getThreadGroup () public static int activeCount () // get the current number of threads that thread group public static int enumerate (thread tarray []) // the copy to an active thread an array of public native int countStackFrames (); public final synchronized void join (long millis) throws InterruptedException // wait for this thread to die, this guy did not patience, over a period of time will not wait .public final synchronized void join (long millis, int Nanos) throws interruptedException // Nothing method PUBLIC FINAL VOID JOIN () THROWS InterruptedException // This guy is very patient, in order to take the heritage, wait for his father to die, Publici (Boolean on) public Final Boolean Isdaemon () PUBLIC Final void checkaccess () // This seems to be a publicpublic string toString () public classloader getContextClassLoader () // We rarely use ClassLoader
Public Void SetContextClassLoader (ClassLoader Cl) Public Static Native Boolean Holdslock (Object Obj) // This thread has a synchronous lock of the specified object, which is used for assertion.