码迷,mamicode.com
首页 >  
搜索关键字:threading    ( 3244个结果
Web静态服务器-4-多线程
#coding=utf-8 import socket import re import threading class WSGIServer(object): def __init__(self, server_address): # 创建一个tcp套接字 self.listen_socket = ...
分类:编程语言   时间:2019-03-04 09:17:56    阅读次数:177
多线程-共享全局变量
运行结果: 列表当做实参传递到线程中 运行结果: 总结: 在一个进程内的所有线程共享全局变量,很方便在多个线程间共享数据 缺点就是,线程是对全局变量随意遂改可能造成多线程之间对全局变量的混乱(即线程非安全) ...
分类:编程语言   时间:2019-03-03 09:37:50    阅读次数:195
threading RLock 可重入锁
threadingRlock多线程代码importthreadingimporttimelock=threading.RLock()print(lock.acquire())defsub(l):print(‘{}:{}‘.format(threading.current_thread(),l.acquire()))print(‘{}:{}‘.format(threading.current_thr
分类:其他好文   时间:2019-02-28 19:58:53    阅读次数:173
UDP实现一个简易的聊天室 (Unity&&C#完成)
效果展示(尚未完善) using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Threading; using System.Net; using System.Net.S ...
分类:编程语言   时间:2019-02-27 20:19:28    阅读次数:295
Python生产者和消费者
# Author:XiangLiangimport threading,timeimport queueq = queue.Queue(maxsize=10)def Producer(name): count = 1 while True: q.put("骨头 %s" %count) print(" ...
分类:编程语言   时间:2019-02-27 01:33:47    阅读次数:173
threading Condition方法
主要用于生产者,消费者模型消费者消费速度大于生产者生产速度例子classDispatcher:def__init__(self):self.data=Noneself.event=threading.Event()defproduce(self,total):for_inrange(total):data=random.randint(0,100)logging.info(data)self.da
分类:其他好文   时间:2019-02-26 21:05:45    阅读次数:176
Python 多线程 实例
多线程实例 1 import threading 2 import time 3 4 5 def eat(): 6 eatTime = time.time() 7 for i in range(30): 8 print('count = {}'.format(count)) 9 time.sleep ...
分类:编程语言   时间:2019-02-26 15:40:11    阅读次数:160
threading.Timer 延迟执行实例代码
threading.Timer实现延迟执行的实例代码importtimeimportthreadingimportloggingFORMAT="%(asctime)s%(threadName)s%(thread)d%(message)s"logging.basicConfig(format=FORMAT,level=logging.INFO)defworker():logging.info(‘in
分类:其他好文   时间:2019-02-25 11:55:54    阅读次数:161
threading join方法
threading的join方式使用实例代码importtimeimportthreadingdeffoo(n):foriinrange(n):print(i)time.sleep(1)t_list=[]for_inrange(2):t=threading.Thread(target=foo,args=(10,),daemon=True)t_list.append(t)t.start()forii
分类:其他好文   时间:2019-02-25 00:52:37    阅读次数:154
threading Tread属性
name,ident,is_active参数的演示importthreadingimporttimedefworker():count=0whileTrue:ifcount>5:breaktime.sleep(2)count+=1print(threading.current_thread().name)t=threading.Thread(target=worker,name="worke
分类:其他好文   时间:2019-02-24 01:05:19    阅读次数:200
3244条   上一页 1 ... 59 60 61 62 63 ... 325 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!