Saturday, 24 December 2016

Thread - Functions

Thread
            It is class of java.lang package to create a new thread.
constructors:-
Thread();
Thread(String threadname);
Thread(Runnable);
Thread(Runnable,String threadname);
Methods:-
public void start()  (Start a thread by calling its run method.)
     Causes this thread to begin execution; the JVM calls the run method of this thread.



public void run()  (Entry point for the thread)
            statements with in this method will be executed more than one threads
concurrently.
public void join() throws InterruptedException
            waits for a thread to terminate.
public static int activeCount()
          Returns the current number of active threads in thread group.
public void stop()     
public void suspend()           
public void resume()
public static Thread currentThread()     
public static void sleep(long ms) throws InterruptedException;
            Suspend a thread for a period of time.
public String getName();
            Obtain a thread’s name.
public void setName(String);
            set Thread’s Name.
public boolean isAlive();
            Determine if a thread is still running.
public void setPriority(int);
            Set a thread’s priority.like
   Thread.MIN_PRIORITY              -           1
   Thread.NORM_PRIORITY           -           5

   Thread.MAX_PRIORITY             -           10

No comments:

Post a Comment

Featured post

Development Of JAVA Program