Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
import threading, multiprocessing, asyncio # Threads — I/O bound t = threading.Thread(target=fetch_data, args=(url,)) t.start(); t.join() # Processes — CPU bound with multiprocessing.Pool() as pool: results = pool.map(heavy_compute, data_chunks) # Asyncio — I/O bound, single thread async def main(): results = await asyncio.gather(fetch(u1), fetch(u2), fetch(u3)) asyncio.run(main())
Result
Open