Search code examples
javamultithreadingunzip

Multithreaded files unzip using java.util.zip.ZipEntry


I'm using:

java.util.zip

I have a while loop reading the buffer until it's clear. I'm reading 2 or more files from a folder but i want something faster. I want to use Threads. If i use a thread for every file then when i unzip a 1GB file i'm not going to see any difference when unzipping smaller files too.

How can i share that job with Threads? I can't read the stream from different Threads (can i?).


Solution

  • The average today’s computer handles zip decompression much faster than a harddisk can provide the data. This applies to most SSDs as well as the bus is the limiting factor.

    So any attempt to speed up the process by changing the CPU utilization will fail. The best thing you can do is to separate reading and writing which might add a gain if source and target are on different devices.

    Or to make the processing after the decompression multi-threaded. But if you are just reading and dropping the data there is no way to accelerate the process significantly.