What is thread? Why we use Thread? (java)
Thread: is independent dispatch-able unit to cpu. each thread can execute an independent module in parallel with CPU.
Thread is also known as light weight process. Each process can contain multiple threads.
Threads will share the resources of its process.
Why to use a thread: Generally your CPU might have the capability of running multiple tasks at a time by using its threads.
But programmer has to support this by creating multiple threads for his program where ever it is possible.
If your program is having two modules, and there is no dependency between those two modules, then
your program can run faster if you run both the modules at a time (in parallel). This can be done only
if you are running those two modules in two different threads.
Back To Top