login每天学习一点点,每天进步一点点.
当前位置:首页 >> 多线程学习第一案例

多线程学习第一案例

2015-12-29 20:46:00  |  分类: Python |  标签: 阅读(254)评论(0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : c32 (amd5@qq.com)
# @blog    : http://cx7863.blog.163.com/
# @Version : 1.0  @Date    : 2015-12-29 20:44:25
import threading
import time
#多线程学习
class ThreadClass(threading.Thread):
  def run(self):
   now = time.time()
   print "says Hello World at time: %s" % now
   (self.getName(), now)

for i in range(20):
  t = ThreadClass()
  t.start()



#================================================================

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : c32 (amd5@qq.com)
# @blog    : http://cx7863.blog.163.com/
# @Version : 1.0  @Date    : 2015-12-29 21:00:00
import threading
import datetime
        
class 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(20):
     t = ThreadClass()
     t.start()

#IBM官方多线程教学   http://www.ibm.com/developerworks/cn/aix/library/au-threadingpython/

#===============================================================

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : c32 (amd5@qq.com)
# @Blog    : http://cx7863.blog.163.com/
# @Version : 
# @DateTime:  2015-12-29 22:30:50

import datetime
import threading


class 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(10):
     t = ThreadClass()
     t.start()

#多线程案例
上一篇:ubuntu使用nmap查询端口 下一篇:ThinkPHP5 的视图$view->fetch()和$view->display()的区别

猜你喜欢

发表评论:

0.207112s