Thread类

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading;
 6 
 7 namespace Consoleapplication
 8 {
 9     //类名Program
10     class Program
11     {
12         public static void myStaticThreadMethod()
13         {
14             Console.WriteLine("myStaticThreadMethod");
15         }
16         static void Main(string[] args)
17         {/*
18             //goto使用(死循环)
19             //int a = 0;
20             //goto skip;//跳转到skip标签
21             //back:a++;//定义back
22             //skip:Console>WriteLine(a);//定义skip标签
23             //goto back;//跳转到back标签
24             //if else else if//猜数字
25 
26             int b = new Random().Next(105);//随机数1~105
27             int cout = 0;
28             Console.WriteLine("random number 1~105,please guess");
29             again:
30             int Input = 0;
31             bool isInputError = int.TryParse(Console.ReadLine(), out Input);
32             if (!isInputError)
33                 goto again;
34             if (Input < b || Input > b)
35             {
36                 Console.WriteLine(Input < b ? "small" : "big");
37                 cout++;
38                 goto again;
39             }
40             else
41                 Console.WriteLine("bingo",cout);
42             Console.WriteLine("what is your level");
43             switch (cout)
44             { 
45                 case 1:
46                 case 2:
47                     Console.WriteLine("hightest");
48                     break;
49                 case 3:
50                 case 4:
51                 case 5:
52                     Console.WriteLine("the second level");
53                     break;
54             }*/
55 
56             Thread thread1 = new Thread(myStaticThreadMethod);
57             thread1.Start();//使用start方法,线程运行
58             //thread1.close();
59 
60 
61             //Console.WriteLine("Hello World");//输出语句
62             //Console.ReadKey();//使输出窗口停留
63             Console.ReadLine();//接受输入值关闭窗口
64 
65         }
66     }
67 }

 

posted on 2018-09-19 15:12  fortwater  阅读(138)  评论(0编辑  收藏  举报

导航