Methods of thread class

start ()

                         void start ();

            start () is non static method of Thread class it is used to start or activate the thread of invoking object.

stop ()

                                    void stop () ;

            stop () is non static method of Thread class it is used to stop the activated thread or running thread. After stopping the thread, we can start the execution process of thread by calling start() method.

suspend ( )

                                    void suspend ();

            suspend () is non static method of Thread class it is used to pause the execution of invoking thread.

resume ()

                                    void resume ( );

            resume () is non static method of Thread class, it is used to resume (restart) the execution process of suspended thread of invoking object.

isAlive ()

                                    boolean isAlive()

            isAlive() is non static method of Thread class, it is used to check whether the invoking thread is started or stopped. If the thread is started or running then this method will return true otherwise returns false.

sleep ()

                                    static void sleep(long milliseconds) throws InterruptedException

                                    sleep() is static method of Thread class. It is used to generate delay between two statements, during the execution of sleep () method execution control will not execute the next instruction up to the given number of milliseconds and when the sleep time is timeout then it will execute the next instruction. During sleep time, execution control will execute the instructions of waiting threads.

join ()

                                    void join();

                                    whenever java interpreter executes any block containing join () statement then interpreter will allow all the joined thread to enter into process state and it will execute the instructions of all the joined thread but after the complete execution of joined thread it will execute the next instructions of current thread(parent thread).

wait ()

                                    void wait();

                                    wait () is native method present in all the classes used to suspend the execution process of thread in which the invoking object is running.

notify ()

                                    void notify()

                                    notify() is native method present in all the classes used to wake up the thread that is in wait state on this monitor object.

notifyAll()

                                    void notifyAll()

                                    notifyAll() is native method present in all the classes used to wake up all the thread that are waiting on this monitor object.

Leave a Reply

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