1》模拟线程池,生产者消费者问题using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;...
分类:
编程语言 时间:
2014-11-12 00:28:17
阅读次数:
539
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
namespace观察者模式
{
classProgram
{
staticvoidMain(string[]args)
{
看NBA的同事zhangSan=new看NBA的同事(){Name="张三"};
看NBA的同事li=new看NBA的同..
分类:
其他好文 时间:
2014-11-11 02:05:56
阅读次数:
185
一个类,有静态方法,并不表明这个类是静态类其次,静态方法,是不能被派生类继承的。例如: System.Threading.WaitHandle这个类中的静态方法WaitAll和WaitAny并没有被其派生类AutoResetEvent和ManualResetEvent所继承
using System;using System.Collections.Generic;using System.IO;using System.Threading;using System.Xml;namespace Helper{ public class SitemapXml { ...
分类:
Web程序 时间:
2014-11-10 13:42:32
阅读次数:
224
先发服务端的(Server)完整代码如下: using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Net.Sockets;
using?System.Net;
using?System.Threading;...
using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Text;using System.Threading.Tasks;namespace RemoveDupRo...
分类:
其他好文 时间:
2014-11-07 18:54:55
阅读次数:
150
涉及的知识有泛型,委托,多线程 实现了延迟执行一个函数,可以指定延迟时间,延迟的 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading....
threading
time
Producer(threading.Thread):
run(self):
count
True:
con.acquire():
count>1000:
con.wait()
:
count=count+100
msg=self.name++str(count)
msg
con.notify()
con.release()
time.sleep(1)
Consumer(threading.Thread):
run(self):
count
True:
con.acqu..
分类:
编程语言 时间:
2014-11-06 17:47:36
阅读次数:
239
线程锁#!/usr/bin/pythonimportthreadingimporttimeclassMyThread(threading.Thread):def__init__(self,threadname):threading.Thread.__init__(self,name=threadname)设定线程名称defrun(self):globalxlock.acquire()加锁foriinrange(3):x=x+1time.sleep(2)printxlock.release..
分类:
编程语言 时间:
2014-11-06 15:03:13
阅读次数:
151
在System.Threading命名空间下,包含了用于创建和控制线程的Thread类。对线程的常用操作有:启动线程、终止线程、合并线程和让线程休眠等。 1. 启动线程 在使用线程前,首先要创建一个线程。其一般形式为:Thread t=new Thread(enterPoint); 其中enterP...
分类:
编程语言 时间:
2014-11-05 12:46:42
阅读次数:
210