Add parallel/README.md

This commit is contained in:
2025-02-16 04:21:55 +00:00
parent 3f220f1811
commit 60dee8d6d4

13
parallel/README.md Normal file
View File

@@ -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)
```