Add thread-python/README.md

This commit is contained in:
2025-02-22 10:46:48 +00:00
parent 054cdf6d31
commit 083e52ac94

13
thread-python/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)
```