Multi Threaded Programming
Multi Threaded Programming
PROGRAMMING
Introduction
Thread: A sequence of instructions executed
within the context of a process.
A program that contains multiple flows of control
is known as multithreaded program.
Multithreaded is a conceptual programming
paradigm where a program (process) is divided
into two or more subprograms (processes), which
can be implemented at the same time in parallel.
Concurrency And Lightweight Thread
Concurrency : A condition that exists when at
least two threads are making progress. A more
generalized form of parallelism that can include
time-slicing as a form of virtual parallelism.
Main method
module
switching switching
suspend resume
sleep notify
wait
stop
Newborn
Runnable Dead
state state
Runnable State
The runnable state means that the thread is ready for
execution and is waiting for the availability of the
processor.
That is, the thread has joined the queue of threads that
are waiting for execution.
If all threads have equal priority, than they are given
time slots for execution in round robin fashion.
The process of assigning time to threads is known as
time-slicing
yield
Running
Thread
Runnable Threads
Running State
Running means that the processor has given its time
to the thread for its execution.
The thread runs until it relinquishes control on its
own or it is preempted by a higher priority thread.
resume, after(t)
notify