内容显示页
 
类别:.Net + C# | 浏览(15746) | 2008-4-10 12:59:09

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace 线程练习
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("开始一个新的线程,名为次线程");
            Thread t = new Thread(new ThreadStart(ThreadProc));
            t.Start();
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine("主线程:" + i);
                Thread.Sleep(1000);
            }
            Console.WriteLine("调用Join函数等待次线程结束");
            //当次线程执行完毕后,Join阻塞调用线程,直到某个线程终止为止,本例为次线程
            t.Join();
            Console.WriteLine("线程执行完毕");
        }
        public static void ThreadProc()
        {
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("ThreadPorc:{0}", i);
                Thread.Sleep(1000);//将当前进程阻塞指定的毫秒数
            }


        }
    }
}

引用本页地址:http://www.yongfa365.com/item/CDuoXianChengJianDanLiZi.html
 
 
相关链接
 
网友评论:
1 匿名网友 - 2009-8-8 18:55:49
我是初学者,感觉还是有点难了!
 
2 SEO中国 - 2009-9-15 19:50:21
写得不错啊!很简洁!
 
3 匿名网友 - 2010-4-19 14:55:16
简明扼要 支持
 
4 匿名网友 - 2010-4-19 14:55:40
...
 
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
.Net + C#(73)
 
 
ASP+VBS(161)
 
 
 
Linux(10)
 
 
 
web 2.0(26)
 
 
 
 
 
心程(68)
 
生活(97)
 
 
     

Power by :柳永法(yongfa365)'Blog  | 京ICP备07011491号  QQ:64049027  E-mail:64049027@qq.com yongfa365'CodePlex yongfa365'CodeGoogle

申请友情链接 要求:跟本站主题相类似正规网站,双方交换为首页位置

转载请注明来源,以便后人及时得到最新、修正、加强版!!!