Please enable JavaScript.
Coggle requires JavaScript to display documents.
LLD - Coggle Diagram
LLD
-
Java Concurrency
Basics
Thread subprocess/Light weight process
-Smallest Unit of execution that can be scheduled by an OS
SW
OS
Hardware
Threads share memory and resources within the same process. THAT IS WHY quesiton of concurrency and parallelism arises.
-
-
ThreadPool
Queue<Tasks> taskQueue;
Using a ThreadPool is beneficial because it helps manage and reuse threads efficiently, avoiding the overhead of creating and destroying threads for each task. Additionally, it allows you to control the number of concurrent threads, which is important for managing system resources.
It reduces the number of thread creation in that particular action
ExecutorService service=Executors.newFixedPoolThread();
-
-
Process is an instance of program execution, or in other words simply an executing or active program.
when you run some software or a web browser: they are distinct processes
the OS assigns distinct registers, program counters, heap and stack memories to every process
processes are totally independent and they have no shared memory or data
context switching and communication between processes is more time-consuming since they are heavy, creating new processes requires more resources compared to threads
-
-
-
-
ThreadLocal
Per thread instance, local to the thread.
-
-
-
-