0w0
[thread] 함수 형태의 thread, 클래스 형태의 thread 본문
728x90
반응형
#함수 형태로 thread 적용
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import threading
import time
def thread_run():
print('Thread running -Test')
def thread_run_msg(msg):
print('Thread running -Test',msg)
start_time=time.time()
for i in range(1000):
t1=threading.Thread(target=thread_run)
t2=threading.Thread(target=thread_run_msg,args=('service',))
t1.start()
t2.start()
print(time.time()-start_time)
|
cs |
#클래스 형태로 thread 적용
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import threading import time class Thread_Run(threading.Thread): def run(self): print('Thread running -Test') start_time=time.time() for i in range(1000): t=Thread_Run() t.start() print(time.time()-start_time) | cs |
728x90
반응형
'Coding > Python' 카테고리의 다른 글
[requests] html_parsing 함수 (0) | 2019.12.22 |
---|---|
[selenium wait] Implicitly wait 및 Explicitly wait (0) | 2019.09.01 |
[pyqt] GUI 관련 모듈 및 엔진 (작성중) (0) | 2019.08.26 |
[selenium] python selenium cheat sheet (0) | 2019.08.25 |
[parser] requests.get(), urllib.request.urlopen().read() (0) | 2019.08.20 |
Comments