September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,9 +1,14 @@
|
|||
from __future__ import print_function
|
||||
from multiprocessing import Pool
|
||||
import random, sys, time
|
||||
import threading
|
||||
|
||||
def main():
|
||||
p = Pool()
|
||||
p.map(print, 'Enjoy Rosetta Code'.split())
|
||||
lock = threading.Lock()
|
||||
|
||||
if __name__=="__main__":
|
||||
main()
|
||||
def echo(s):
|
||||
time.sleep(1e-2*random.random())
|
||||
# use `.write()` with lock due to `print` prints empty lines occasionally
|
||||
with lock:
|
||||
sys.stdout.write(s)
|
||||
sys.stdout.write('\n')
|
||||
|
||||
for line in 'Enjoy Rosetta Code'.split():
|
||||
threading.Thread(target=echo, args=(line,)).start()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue