diff --git a/parallel/README.md b/parallel/README.md new file mode 100644 index 0000000..660596c --- /dev/null +++ b/parallel/README.md @@ -0,0 +1,13 @@ +```python +def worker(x): + __import__('time').sleep(1) + print(x, end=' ') + return x ** 3 + +with __import__('concurrent').futures.ThreadPoolExecutor(64) as T: + y = list(T.map(worker, range(100))) +# 64개 worker로 100개의 1초 소요되는 작업: 2초후 종료 + +# x는 순서대로 호출 안되지만 y는 순서대로 나옴 +print(y) +``` \ No newline at end of file