Thread
Thread is a individual program execution path. Each thread has different stack, threads share some memory space.
Performing multiple task parallely is known as multitasking and it is achieved by developing multi threaded application.
Process uses different memory space and context switching between process is difficult whereas context switching between threads is easy.
Establishing communication between processes is also complex whereas establishing communication between threads is also easy.
When we execute Java class three threads are created by JRE:
- Main thread
- Threads scheduler
- Garbage collection thread
Main Thread:- It executes all the statements written in a main method. From main thread we can create our own n number of threads i.e, user defined threads.
Threads scheduler:- It manages all the threads which are currently running and it allocates CPU time for each threads which are running currently.
Garbage collection thread:- It manages the memory, it will kill if any abundant object exist.
0 Comment(s)