標籤:time rar color 編程 date pre import logs cli
w
使用 Python 進行線程編程
https://www.ibm.com/developerworks/cn/aix/library/au-threadingpython/index.html
import threadingimport datetimeclass ThreadClass(threading.Thread): def run(self): now = datetime.datetime.now() print "%s says Hello World at time: %s" % (self.getName(),now)for i in range(2): t = ThreadClass() t.start()
C:\>python E:\MATHpyCLI\au-threadingpython.pyThread-1 says Hello World at time: 2017-04-29 15:07:00.141000Thread-2 says Hello World at time: 2017-04-29 15:07:00.143000C:\>python E:\MATHpyCLI\au-threadingpython.pyThread-1 says Hello World at time: 2017-04-29 15:07:02.312000Thread-2 says Hello World at time: 2017-04-29 15:07:02.313000C:\>python E:\MATHpyCLI\au-threadingpython.pyThread-1 says Hello World at time: 2017-04-29 15:07:03.116000 Thread-2 says Hello World at time: 2017-04-29 15:07:03.118000
使用 Python 進行線程編程