Skip to content

Commit 62b44d5

Browse files
Create thread function with args
1 parent 8acef32 commit 62b44d5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/script14.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import time
2+
from threading import Thread
3+
4+
def ThreadFunction(x):
5+
print "sleeping 5 sec from thread %d" % x
6+
time.sleep(5)
7+
print "finished sleeping from thread %d" % x
8+
9+
def Main():
10+
for i in range(10):
11+
myThread = Thread(target=ThreadFunction, args=(i,))
12+
myThread.start()
13+
14+
if __name__ == "__main__":
15+
Main()
16+

0 commit comments

Comments
 (0)