Some Important Methods defined in java.lang.Thread are shown in the table:

1.    Thread currentThread( ) : Returns an object reference to the thread in which it is invoked.

 

2.    String  getName( )  :Retrieve the name of the thread object or instance.

 

3.      void  start( ) :Start the thread by calling its run method.

 

4.    void  run( )  :This method is the entry point to execute thread, like the main method for applications.

 

5.      void  sleep( ):Suspends a thread for a specified amount of time (in milliseconds).

 

6.    boolean  isAlive( ) : This method is used to determine the thread is running or not.

 

7.    int  activeCount( ) :This method returns the number of active threads in a particular thread group and all its subgroups.

 

8.      void  interrupt( ) :The method interrupt the threads on which it is invoked.

 

9.    void  yield( ) :By invoking this method the current thread pause its execution temporarily and allow other threads to execute.

 

10.  void  join( ) :This method and  join(long millisec) Throws InterruptedException. These two methods are invoked on a thread. These are not returned until either the thread has completed or it is timed out respectively.

 

A thread in Java can be created in 2 ways. Read More:

 

Program to create multiple threads using Thread class

Program to create multiple threads using Runnable interface




Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on javagenious.com(At)gmal.com ; I would like to hear from you :)