This is an introduction to Java concurrency and multithreading on a conceptual
level, so it does not contain any code examples.
In the early days of computing, a computer could only run one program or process at
a time. Modern computers typically come with multiple CPUs or CPUs with multiple
cores, which in practice is the same thing. So, on a modern computer, you might
actually have multiple CPUs executing these applications. Some of these
applications and threads are not exactly executing at the same time, but some of
them will be because of the multiple CPUs.
Multithreading is better for IO utilization. In the following example, we have a
thread running within an application. This thread needs to load some data from the
disk, then it loads the next data and then processes that data, etc. In this way,
we can better utilize the CPU while IO tasks are running. Another benefit is higher
application responsiveness as perceived by the user.
Multithreading is important in computer programming, but it comes with its own set
of issues that we must learn to handle.
level, so it does not contain any code examples.
In the early days of computing, a computer could only run one program or process at
a time. Modern computers typically come with multiple CPUs or CPUs with multiple
cores, which in practice is the same thing. So, on a modern computer, you might
actually have multiple CPUs executing these applications. Some of these
applications and threads are not exactly executing at the same time, but some of
them will be because of the multiple CPUs.
Multithreading is better for IO utilization. In the following example, we have a
thread running within an application. This thread needs to load some data from the
disk, then it loads the next data and then processes that data, etc. In this way,
we can better utilize the CPU while IO tasks are running. Another benefit is higher
application responsiveness as perceived by the user.
Multithreading is important in computer programming, but it comes with its own set
of issues that we must learn to handle.