Understanding concurrency
Have you ever wondered how many tasks a computer can truly run simultaneously? It’s tempting to say several, yet, in reality, a single-core computer can only execute one process at a given instant. This might appear as simultaneous due to the impressive speed at which CPUs switch between processes, thus creating the illusion of simultaneous multitasking.
Concurrency is the concept of executing multiple tasks or threads at the same time, rather than sequentially. In a sequential system, tasks are executed one after the other, with each task waiting for its predecessor to complete before starting.
For our Java applications, concurrency refers to executing different segments of a program, simultaneously. The term simultaneously might be a little ambiguous here, as it could mean multiple things – and that is because concurrency can occur at the hardware level, such as in multi-core processors, or at the software level. An OS could schedule...