About multithreading download disadvantages About multithreading download disadvantages multithreading multithreading

About multithreading download disadvantages


I assume you're referring to download managers.

First, I'm sceptical of how much "performance" benefit a download manager really provides. But more importantly, any benefit they do provide is not due to multi-threading. The performance constraint of a download is the bandwidth of the connection. And this is why I'm sceptical of the benefits:

  • A 1 Mbps connection will download at 1 Mbps.
  • Splitting the file into 4 segments means you download each segment at 256 Kbps and 4 * 256 Kbps = 1 Mbps.
  • You may get some improvement if a server throttles each download segment.
  • You may get a small benefit if one of the segments gets timed out: the others downloading mean your connection doesn't sit idle during the time-out wait.
  • You might also speed up a download by 'drowning out' anything else trying to use the connection. (Not that I'd really call this a benefit though.)

The real benefit of a download manager is in automatically restarting downloads efficiently (i.e. not re-starting from scratch if possible).

So what is the point of multi-threading?

Let's first dispel a myth: Multi-threading does not speed anything up. If a routine requires X clock-cycles to run: it will take X clock-cycles; whether on 1 thread or many threads.

What multi-threading does do: it allows tasks to run concurrently (at the same time).

The ability to do different things at the same time means:

  • A slow task (combining various segments of a large download) can be done on a different thread without interfering with other threads that need to react quickly (such as the user interface).
  • Concurrent tasks can also use more available resources (multiple CPUs) more efficiently. Note (in answer to the last part of your question) if you only have one CPU then your threads are "time-sliced" by the operating system so it's not truly concurrent. But the time slices are very small, so previous benefit still applies.

When is single-threaded faster than multi-threaded?

Well, pretty much always in cases where CPU is not the bottle-neck. In the case of download: As mentioned before, the bottle-neck is the bandwidth between the two end-points of the connection. Many threads actually means you have to do more work (managing and coordinating the different threads).

The most efficient approach for download is 2 threads: one for the UI, and the other for the download so that any pauses/dealys don't stall the user interface.

However, more generally even when you have CPU intensive work that could theoretically benefit from multiple threads doing different work concurrently, it's very easy to make mistakes in implementation that actually slow down your application.

  • Ideally your multiple tasks should not share data. Because if they do, then you risk race-condition or concurrency bugs.
  • When they do have to share data, you need to synchronise the work in some way to avoid the above mentioned bugs. (There are many techniques to choose from depending on your needs and I won't go into detail here.)
  • However if your synchronisation is poorly planned you risk introducing a number of problems that can significantly slow down your application. These include:
    • Bottle-necking through a shared resource to make your multiple threads unable to run concurrently in any case.
    • High lock contention where task spend more time waiting than working.
    • Even deadlocking which can totally block some tasks.


First of all, what Multi-Threading download does, it creates multiple threads, which download the file from different starting positions, which tries to utilize maximum power of your internet connection. (This will download fast in multi-core processor case, which is explained below).

We might feel threads running parallel, but actually, they are supposed to run turn by turn. For example thread t1 runs for 0.25 sec, then thread t2 runs for 0.241 sec, and then t1,.., t2,, t1. So, they share CPU Bursts.

  • So why Multi-threads improve performance?Answer: If you have multi-core processor, threads can be managed to run parallel using multiple processors, which improves performance. (This is how download accelerators like IDMan do the magic!).
  • Why Multi-threads degrade performance?Answer: If you have single-core processor, all threads will run turn by turn, as a single process, sharing CPU Bursts. In this case, monothread download is faster than multithread, because if you use multi-threads, some time is wasted while switching from one thread to another. (Download accelerators like IDMan will not really download fast in this case despite multi-threaded download).

See this picture having dual core processor, and how threads are managed.Picture Showing threads in multi-core processor

I hope this helps! :-)