Methods of Thread class

MethodDescription
  run ()The run() method is a method which contain behavior & entire body of a thread. It is the soul of a thread.  
    start ()It is a method with the help of which run() method is invoked by an object of the related(concerned) thread.
Method run()cannot be directly call, we call start()method then it invoked run() method.
  sleep (t)This method is used to stop the execution of a thread for a particular period of time given in milli-seconds.    
    suspend () deprecatedIt is kind of a blocking method. This method suspends the execution of a thread until it receives an order to relief it.  
  wait  ()This method is also a blocking method, it stops execution of a thread until certain condition occurs.  
  resume () deprecatedThis method give’s an order to relief a thread from suspend condition.
  notify ()  This method is used for waking up a thread from wait condition and move it again in a runnable state.  
    yield ()  This method is used to relinquish control from a thread to another thread of equal priority before its turn comes.  
  currentThread()  The currentThread () gives the name, priority, and group name of a thread.  
  getName ()This method gives the name of a thread.  
  setName ()The method setName () is used to rename a thread.  
  getPriority ()This method is used to getting the priority of a thread.  
    setPriority (int)A setPriority (int) method is a method which is used to set the priority of a thread.  We can set priority of a thread in integer range between 1-10.   
    isAlive ()The isAlive () method is a method with a boolean return type, it returns true if the thread upon which it is called is still running.  
     join ()This method waits until the thread on which it is called is terminated.
This method is useful for knowing that whether a thread is alive or not.
stop() deprecatedTo kill the thread.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.