fork(1) download
  1. import threading
  2.  
  3. def printer(num):
  4. for i in range(5):
  5. print(num)
  6.  
  7. def main():
  8. threads = []
  9. for i in range(10):
  10. t = threading.Thread(target=printer, args=(i,))
  11. threads.append(t)
  12. for t in threads:
  13. t.start()
  14. for t in threads:
  15. t.join()
  16.  
  17. if __name__ == '__main__':
  18. main()
  19.  
Success #stdin #stdout 0.02s 706048KB
stdin
Standard input is empty
stdout
0
0
0
0
0
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
4
4
4
4
4
5
5
5
5
5
6
6
6
6
6
7
7
7
7
7
8
8
8
8
8
9
9
9
9
9