using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Net;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.IO;
using System.Collections;

namespace ConsoleApplication1
{

public class prodert
{
private string urls;
private string name;
public string Name
{
set { this.name = value; }
get { return this.name; }
}

public string Urls
{
set { this.urls = value; }
get { return this.urls; }
}
}

class IPSearch
{
static Queue<prodert> q = new Queue<prodert>();
public static object a = new object();
static void Main(string[] args)
{

Dictionary<string, string> dic = new Dictionary<string, string>();

for (int i = 0; i < 100; i++)
{
prodert p = new prodert();
p.Urls = "http://www.hao123.com" + i.ToString();
p.Name = "hao123com" + i.ToString();
q.Enqueue(p);
}

Thread t1 = new Thread(new ThreadStart(getQueue));
Thread t2 = new Thread(new ThreadStart(getQueue));
Thread t3 = new Thread(new ThreadStart(getQueue));
t1.Name = "t1";
t1.Start();
t2.Name = "t2";
t2.Start();
t3.Name = "t3";
t3.Start();
Console.ReadKey();
}
private static void getQueue()
{
for (int i = 0; i < 10; i++)
{
aa();
}
}
private static void aa()
{
lock (a)
{
if (q.Count > 0)
{
prodert p1 = q.Dequeue();
Thread.Sleep(100);
Console.WriteLine(p1.Name + p1.Urls+"------"+Thread.CurrentThread.Name);

}
}
}
}
}

最新文章

  1. 最强 Android Studio 使用小技巧和快捷键
  2. Python学习日志(一)
  3. CentOS7.2 编译安装SVN1.9.5客户端
  4. HDU5892~HDU5901 2016网络赛沈阳
  5. android中paint的setXfermode属性
  6. 转: Linux磁盘扩容
  7. 自定义cell的步骤(每个cell的高度不一样,每个cell里面显示的内容也不一样)
  8. BZOJ3103 : Palindromic Equivalence
  9. Matlab位运算操作
  10. Convert Windows 32bit dirver to Windows 64bit
  11. 集群中几种session同步解决方案的比较
  12. BZOJ 3132: 上帝造题的七分钟( 二维BIT )
  13. struts2跳转类型解析
  14. uilabel 复制
  15. “canvas画布仿window系统自带画图软件&quot;项目的思考
  16. 使用HttpClient进行Get方式通信
  17. 【UML 建模】在线UML建模工具 ProcessOn 使用详解
  18. SharePoint Online 自定义Modern UI表单
  19. Go Example--常量
  20. Remote Desktop Session中如何触发Ctrl+Alt+Delete?

热门文章

  1. 149. Best Time to Buy and Sell Stock【medium】
  2. 每日英语:China&#39;s Retirement Age Sets Experts at Odds
  3. ARM获得PC指针为何PC=PC+8
  4. JSP页面最终是编译为Servlet执行的
  5. tomcat Can't create cache file!
  6. sqlserver 关于子查询的优化操作
  7. tomcat架构分析 (connector NIO 实现)
  8. SQL Server 2008 压缩日志
  9. [shell]shell脚本传入不固定参数的写法,如--help等
  10. uboot中变量env(收集)