Skip to content
C

Concurrent Downloads with Threading

Mediumpython

Simulate downloading n files concurrently using threading, then report whether they actually ran concurrently.

Approach: start one thread per "download" (each sleeping briefly to simulate I/O wait), join them all, and compare the total elapsed time against what running them one-after-another would have taken — printing a classification rather than a raw timing value, since exact elapsed time isn't reliably reproducible across machines.

Input: One line: the number of files to "download", n.

Output: Two lines: "Downloaded <n> files", then "Concurrent" if the threads clearly ran in parallel, or "Sequential" otherwise.

Input (stdin)

Output

Run your code to see output here...