Thread. A thread represents an independent module of an application that can be concurrently execution With other modules of the application. MULTITHREADING
A thread represents an independent module of an application that can be concurrently execution
With other modules of the application.
multithreading represents concurrent execution of multiple thread. Multiple thread is a light weight version of multiprocessing is the way that less overhead incurred by the o/s in the management to thread as compared to processes .
(it is non final method)
Syntax:public void run();
Start():- it is responsible for starting the execution of a thread.
Syntax: public void start();
STATES OF THREADS
Scheduling method are executed by the JVM as a thread.algo works here.
Runnable /ready to run
Swaped states over
Control is taken back from the thread by the scheduler
Processor is alloted
Thread is suspended
Defining user thread:
A user thread is represented by the run method , run method can be defined in the following two ways:
Public interface Runnable
Note: thread class provides default implementation of runnable interface .
Note: these methods are defined in object class.
Sleeping for the specified time by invoking a wait method on itself .
Block for I/O
Waiting for joined thread for complete or time out.
Waiting for lock
Wating for notification
Method or some blockesexceuted