摘要:
using System; using System.Threading; internal class Program { private static long _counter = 1; private static void Main() { //下面程序显示两个线程如何并发访问一个名为counter的整形变量,一个线程让他递增5次,一个让他递减5次 Console.WriteLine("原始值:{0}", _counter); var t1 = new... 阅读全文
posted @ 2013-06-23 18:24
清山博客
阅读(378)
评论(0)
推荐(0)
摘要:
using System.Threading;class Program{ static void f1() { System.Console.WriteLine("f1"); } void f2() { System.Console.WriteLine("f2"); } static void f3(object obj) { System.Console.WriteLine("f3 obj = {0}", obj); } static void Main() { //方... 阅读全文
posted @ 2013-06-23 17:55
清山博客
阅读(202)
评论(0)
推荐(0)
摘要:
using System.Diagnostics;class Program{ static void Main() { if (TestIfAlreadyRunning()) { System.Console.WriteLine("This app is already running!"); } else { // Here, the entry point of the application. } } static bool TestI... 阅读全文
posted @ 2013-06-23 17:43
清山博客
阅读(230)
评论(0)
推荐(0)
摘要:
using System.Diagnostics;using System.Threading;class Program{ static void Main() { Process process = Process.Start("notepad.exe", "hello.txt"); //创建子进程,初始的进程为父进程 Thread.Sleep(1000);//父进程的线程在等待1秒后,销毁子进程 process.Kill(); }} 阅读全文
posted @ 2013-06-23 17:41
清山博客
阅读(305)
评论(0)
推荐(0)

浙公网安备 33010602011771号