⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 py_thread.py

📁 unix下解释类c++语言的封装类
💻 PY
字号:
''' Demonstrate the use of python threading'''

import time
import threading

def ThreadFunc():
	for i in range(15):
		print '...Printed from my thread.'
		time.sleep(1)

class MyThread(threading.Thread):
	def __init__(self):
		threading.Thread.__init__(self)
	def run(self):
		for i in range(15):
			print 'printed from MyThread...'
			time.sleep(1)

def createThread():
	print 'Create and run MyThread'
	background = MyThread()
	background.start()
	print  'Main thread continues to run in foreground.'
	for i in range(10):
		print 'printed from Main thread.'
		time.sleep(1)
	print  'Main thread joins MyThread and waits until it is done...'
	background.join() # Wait for the background task to finish
	print  'The program completed gracefully.'
	
	return 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -