Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit adad23a

Browse files
Create thread_with_function.py
1 parent 14d996c commit adad23a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎scripts/thread_with_function.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
import time
3+
from threading import Thread
4+
5+
#create function for thread
6+
def Tfunc(i):
7+
print("%d sleeping 5 sec from thread\n" % i)
8+
time.sleep(5)
9+
print("\n %d finished sleeping from thread" % i)
10+
11+
#start the thread for function
12+
for i in range(5):
13+
t1 = Thread(target=Tfunc, args=(i,))
14+
t1.start()
15+
16+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /