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

Appearance settings

Latest commit

 

History

History
History
40 lines (34 loc) · 734 Bytes

File metadata and controls

40 lines (34 loc) · 734 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import threading
import time
# def p(x):
# time.sleep(1)
# print(x)
#
# for i in range(10):
# p(i)
#
# for i in range(10):
# t = threading.Thread(target=p, args=(i,))
# t.start()
def a():
print('start a')
time.sleep(3)
b()
def b():
print('start b')
t1 = threading.Thread(target=a)
# t1.setDaemon(True) # 为True时主线程不等子线程退出再退出,默认FALSE
t1.start()
t1.setName('NB')
print(t1.getName())
t1.join() # 等子线程结束再往下执行,不再并发执行
t2 = threading.Thread(target=a)
# t2.setDaemon(True)
t2.start()
print(t2.is_alive())
t2.join(2) # 最多等2秒
t3 = threading.Thread(target=a)
# t3.setDaemon(True)
t3.start()
print(t3.isDaemon())
print(t3.ident)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.