Skip to content

Instantly share code, notes, and snippets.

@nattybear
Created May 18, 2017 10:30
Show Gist options
  • Select an option

  • Save nattybear/556b39779c2e97fd0849bde440a36c3e to your computer and use it in GitHub Desktop.

Select an option

Save nattybear/556b39779c2e97fd0849bde440a36c3e to your computer and use it in GitHub Desktop.
Python Multithreaded Programming
import thread
import time
# Define a function for the thread
def print_time(threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
print "%s: %s" % (threadName, time.ctime(time.time()))
# Create two threads as follows
try:
thread.start_new_thread(print_time, ("Thread-1", 2,))
thread.start_new_thread(print_time, ("Thread-2", 4,))
except:
print "Error: unable to start thread"
while 1:
pass
@nattybear
Copy link
Author

nattybear commented May 18, 2017

https://www.tutorialspoint.com/python/python_multithreading.htm

새 쓰레드 시작하기

쓰레드를 실행하려면 thread 모듈의 다음 메서드를 사용한다.

thread.start_new_thread(function, args[, kwargs])

이 메서드를 사용하면 윈도우와 리눅스에서 모두 효율적이고 빠르게 쓰레드를 실행 할 수 있다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment