Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Explain the difference between concurrency and parallelism, with one Java example of each. Can a program be concurrent on a single CPU core, and can parallel streams speed up an I/O-bound task?

Concurrency means structuring a program as several tasks that make progress over overlapping periods of time; parallelism means actually running work at the same instant on several cores. A web server handling many requests that mostly wait on I/O is concurrency; list.parallelStream().mapToLong(this::heavyCalc).sum() splitting CPU work across cores is parallelism. A single core can be concurrent by interleaving tasks, but not parallel, and parallel streams do not help I/O-bound work because they run on a small common pool that blocking calls starve.

Why this question is asked

The two words are often used as synonyms, but they describe different things, and mixing them up leads to real mistakes, such as using parallel streams to speed up HTTP calls or sizing a thread pool for the wrong kind of work. Interviewers ask this to check that we can tell whether a task is limited by waiting or by computing, because the right tool depends on it. In this answer, we will define both terms with a picture, look at one Java example of each, see how a single core can still be concurrent, and explain why parallel streams are the wrong tool for I/O-bound work.

1Two Different Questions

Concurrency is about structure. A concurrent program is written as several independent tasks, such as one per request, that can be in progress at the same time. Whether they actually run at the same instant is a separate question. The goal is usually responsiveness: while one task waits for a database, another can make progress.

Parallelism is about execution. A parallel program splits one piece of work into parts and runs them at literally the same moment on different CPU cores, to finish sooner. The goal is speed on work that keeps the CPU busy.

So concurrency is about dealing with many things at once, and parallelism is about doing many things at once. A program can be concurrent without being parallel, parallel without much concurrency in its design, or both.

Concurrency and parallelism side by side
ConcurrencyParallelism
Main ideamany tasks in progress over overlapping timework running at the same instant
Needs several cores?noyes
Typical limitwaiting on I/OCPU time
Java examplea server with a thread per requestparallelStream over CPU-heavy work
Goalresponsiveness, throughput of waiting tasksfinish one job sooner

2A Concurrency Example: a Server Handling Requests

A web server is the classic concurrent program. Each request runs in its own thread, and most of a request's time is spent waiting: for the database, for another service, for the client to send bytes. While one thread waits, the operating system or the JVM runs another. With virtual threads, the JVM does this even more cheaply, parking the waiting virtual thread and reusing its carrier thread.

Java
try (ExecutorService exec = Executors.newVirtualThreadPerTaskExecutor()) {
for (int i = 0; i < 10_000; i++) {
int id = i;
exec.submit(() -> handleRequest(id)); // each waits ~50 ms on a database
}
} // the waits overlap: far less than 10,000 x 50 ms = 500 s, if the database keeps up

Notice that the speed-up here has nothing to do with the number of cores. The tasks spend almost all their time waiting, so even a machine with 2 cores can keep 10,000 of them in progress at once. That is concurrency.

3A Parallelism Example: Splitting CPU Work

Now take a task that keeps the CPU busy, such as calculating a score for a million records. Here there is nothing to wait for; the only way to finish sooner is to use more cores at the same time. A parallel stream splits the list into chunks and runs them on the threads of ForkJoinPool.commonPool(), plus the calling thread.

Java
long total = records.parallelStream()
.mapToLong(this::heavyCalc) // about 1 ms of pure CPU each
.sum();
// 1,000,000 records: about 1,000 s on one core, about 125 s on 8 cores

This is parallelism: the same work divided and executed simultaneously. The speed-up is limited by the number of cores, and by the cost of splitting and combining, which is why parallel streams rarely help for small lists or cheap operations.

4Can a Single Core Be Concurrent?

Yes. On a single core, the operating system gives each runnable thread a short time slice and switches between them, and threads that are waiting on I/O do not need the CPU at all. So many tasks are in progress over the same period, which is concurrency, even though at any instant only one instruction stream is running. There is no parallelism on one core.

This is exactly how servers worked for decades on single-core machines, and it is why concurrency improves the throughput of waiting tasks even without extra cores. But the same interleaving does nothing for CPU-bound work: splitting a 10-second calculation into four threads on one core still takes 10 seconds, plus switching overhead.

5Why Parallel Streams Do Not Help I/O-Bound Work

Parallel streams run on the common ForkJoinPool, which by default has availableProcessors() - 1 worker threads, so 7 on an 8-core machine, and the calling thread also helps. That size is right for CPU work and far too small for waiting. If each element makes a 100 ms HTTP call, at most about 8 calls are in flight at a time, so 1,000 calls take about 12.5 seconds.

Java
List<Price> prices = ids.parallelStream()
.map(client::fetchPrice) // blocks ~100 ms on HTTP
.toList();
// 1,000 ids, 8 threads busy waiting -> about 12.5 s
// with a virtual thread per call -> about 0.1 s plus overhead

Worse, the common pool is shared by the whole JVM. While our stream blocks its threads on HTTP, every other parallel stream and many CompletableFuture stages without an explicit executor have to wait too. For I/O-bound work the right tool is concurrency: a virtual thread per call, or an executor sized for waiting, with a limit set by what the remote service can handle.

6Follow-up questions

Is a multithreaded program always concurrent?

Yes, in the structural sense: having several threads means several tasks can be in progress at once. Whether it is also parallel depends on the hardware and on whether the threads are runnable at the same time. On an 8-core machine, CPU-busy threads usually run in parallel; on one core, they only interleave.

How do you tell whether a task is CPU-bound or I/O-bound?

Measure it. If threads spend most of their time in RUNNABLE state doing computation and CPU usage is near 100 percent per thread, it is CPU-bound. If thread dumps show threads mostly waiting on sockets or locks and CPU is low, it is I/O-bound. A profiler showing wall-clock time versus CPU time makes the split clear.

Can we run a parallel stream in our own pool?

A common trick is to submit the stream from inside a custom ForkJoinPool, which then runs its tasks. It works in practice but is not a documented guarantee of the streams API, so it is better to use an explicit executor for anything that needs isolation, and to keep parallel streams for short CPU-bound work.

7Conclusion

In this answer, we saw that concurrency is about structuring a program as tasks that make progress over overlapping time, while parallelism is about executing work at the same instant on several cores. A server handling many waiting requests is concurrent, and a parallel stream summing CPU-heavy calculations is parallel. A single core can run concurrent tasks by interleaving them but gives no parallelism, and parallel streams do not help I/O-bound work, because their small shared pool, sized to cores minus one, is quickly blocked by waiting calls.

What to say in the interviewAbout 70 seconds aloud

Open with

Concurrency is about structure: the program is made of several tasks that are in progress over overlapping time, like a server handling each request in its own thread, where most of the time is spent waiting on the database.

Then, if they want more

Parallelism is about execution: one job is split and the parts run at the same instant on different cores, like records.parallelStream().mapToLong(this::heavyCalc).sum(), which spreads CPU work over the common ForkJoinPool.

A single core can absolutely be concurrent, since the scheduler interleaves threads and waiting threads do not need the CPU, but there is no parallelism there, and CPU-bound work does not get faster by adding threads on one core. Parallel streams do not help I/O-bound tasks.

The common pool has about availableProcessors minus one threads, so with blocking HTTP calls only around eight calls are in flight at a time on an 8-core machine, and because the pool is shared, the blocking also slows other parallel streams and async stages in the JVM.

For I/O-bound work I would use concurrency instead, for example a virtual thread per call with a limit that protects the remote service.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain the difference between concurrency and parallelism, with one Java example of...": https://scrivio-interview-library.netlify.app/java/threads/cb0a176fcf/

More in Threads