wiki:Pythonの短いソースコード集

Version 1 (modified by nakiki, 13 years ago) (diff)

--

スレッドを作る

import threading
import time

def process():
  while True:
    print 'x1'
    time.sleep(3)

th = threading.Thread(None, process, None)
th.setDaemon(True)
th.start()

while True:
  print 'x0'
  time.sleep(3)