关于线程的,一个金典算法
2014-10-30 14:36
99 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace threaddemo
{
class Program
{
static Thread t;
static DateTime dt;
static void Main(string[] args)
{
t = new Thread(new ThreadStart(methd));
t.Start();
Console.Read();
}
static void methd()
{
dt = DateTime.Now.AddMilliseconds(-1000);
while (true)
{
if (dt.AddMilliseconds(1000) < DateTime.Now)
{
int i = 0;
while( i<5)
{
Console.Write(i.ToString() + ",");
Thread.Sleep(1000);
i = i + 1;
}
dt=DateTime.Now;
}
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace threaddemo
{
class Program
{
static Thread t;
static DateTime dt;
static void Main(string[] args)
{
t = new Thread(new ThreadStart(methd));
t.Start();
Console.Read();
}
static void methd()
{
dt = DateTime.Now.AddMilliseconds(-1000);
while (true)
{
if (dt.AddMilliseconds(1000) < DateTime.Now)
{
int i = 0;
while( i<5)
{
Console.Write(i.ToString() + ",");
Thread.Sleep(1000);
i = i + 1;
}
dt=DateTime.Now;
}
}
}
}
}
相关文章推荐
- 下面是一个关于VB的农历算法office:office
- 一个关于从1到100的加法算法
- 关于栈的一个算法(实现单链表的倒置)
- 一个关于逆运动学的 CCD 和 PIK 算法的说明
- 关于阶乘的两个常见算法及一个相关面试题
- 关于分解质因数的一个算法
- 关于Windows Socket是不是一个线程的多个Socket共享消息泵
- 关于线程的一个练习
- C++ 中关于一个线性时间算法(linear-time algorithm)
- 关于中兴校园程序设计比赛其中一个类似NPC问题的算法
- 发现Python的源代码中关于字符串fastsearch算法的一个笔误!
- 关于异步、线程、委托的一个问题
- 推荐一个关于.NET平台数据结构和算法的好项目
- 关于阶乘的两个常见算法及一个相关面试题
- [导入]关于阶乘的两个常见算法及一个相关面试题
- 关于一个算法的求解
- 关于linux线程实时信号的一个问题
- 『JAVA基础』朋友的需求,关于一个算法
- 一个关于计求质数的算法
- 一个关于拼图算法的问题