Posts

Showing posts from May, 2020

Short Notes - Multi Threading Java

Thread vs Process: - Process actually does not run but threads run. So, internally (in the process) there will be at least one thread which will be doing the actual task/work. - Threads (of the same process) run in a shared memory space, while processes run in separate memory spaces. - Thread is termed as 'light weight process', since it is similar to a real process but executes within the context of a process and shares the same resources (address space/process memory, data) allotted to the process by the kernel. Main Thread: - JVM starts the main thread. - This is the first thread that is created after Java application gets started. - It is the thread from which other 'child' threads will be spawned. - It must be the last thread to finish execution bcz it performs various shutdown actions. Thread class:  (in java.lang package) - states: available as enums in Thread class.               Image: represents the state diagra...