The Basics: What is a CPU Core?
A CPU core is a physical processing unit inside your CPU chip. Think of it as a worker in a factory. A single-core CPU has one worker; a quad-core CPU has four. Each core can independently execute ins
Search for a command to run...
Articles tagged with #multithreading
A CPU core is a physical processing unit inside your CPU chip. Think of it as a worker in a factory. A single-core CPU has one worker; a quad-core CPU has four. Each core can independently execute ins
1. Exclusive Lock(ReentrantLock): Only one thread can acquire the lock at a time. package org.example.concurrency; import java.util.ArrayList; import java.util.List; import java.util.concurrent.locks
A common real-life example of a shutdown hook in Java is when a server application needs to gracefully shut down and release resources when it receives a signal to terminate. For instance, let's say a web server application is running and listening f...
If a system has the P processors that have only got the computation type processes (CPU intensive task) then, Max Size = P or P + 1 If a system has to perform I/O operation then, Max Size = P * (1 + W/S) Wait time (W) is the time a thread spends ...
FixedThreadPool: uses a blocking queue to store tasks CachedThreadPool: uses a synchronous queue of size 1 ScheduledThreadPool: uses a delay queue SingleThreadedExecuter (sequential execution of tasks): uses a blocking queue. The size of the...
Real-life example: For a large data set Multithreading can be used to perform data processing tasks in parallel: The BankDataProcessing class loads the data from a database or file, splits the data into multiple lists for processing in parallel, cr...