E D R , A S I H C RSS

Python Multi Threading

Python —„œŠ” 2€€ thread interface  œณตํ•œ‹ค. ํ•˜‚˜Š” C Šคํƒ€˜ API , ํ•˜‚˜Š” Java Šคํƒ€˜ Thread Object.

‚ฌšฉํ•˜Š” ฐฉฒ•€ งคšฐ „‹จ. Thread class ƒ†ฐ›€’ค Java ฒ˜Ÿ start ฉ”†Œ“œ ํ˜ธถœํ•ดฉด run ฉ”†Œ“œ— ตฌํ˜„œ ‚ดšฉด multithread กœ ‹คํ–‰œ‹ค.

‹คŒ€ „‹จํ•œ ˜ˆ.
~cpp 
import thread
import time

def runOne(args):
	i = 0
	while(1):
		i = i+1
		print "thread : ", i, args
		time.sleep(1)


if __name__=="__main__":
	thread.start_new_thread(runOne, ((1,)))

	for i in range(100000,0,-1):
		print "waiting: ", i
		time.sleep(1)

‹คฅธ ฐจ›˜ ธฐฒ•œกœŠ” Seminar:LightWeightThreads€ žˆ‹ค.
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:08
Processing time 0.0241 sec