Last active
April 12, 2016 07:25
-
-
Save tpdns90321/2a4c5c50c381b8046b342b81cec09464 to your computer and use it in GitHub Desktop.
C# Thread Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
namespace FuncASuspendResum{ | |
class Program{ | |
static Thread A; | |
static Thread B; | |
static void FuncA(){ | |
A.Suspend(); | |
for (int i = 0; i < 100; i++){ | |
Console.WriteLine("A : " + i); | |
} | |
} | |
static void FuncB(){ | |
for (int i = 0; i < 100; i++){ | |
if (i == 15){ | |
A.Suspend(); | |
} | |
Console.WriteLine("B : " + i); | |
} | |
} | |
static void Main(string[] args){ | |
A = new Thread(FuncA); | |
B = new Thread(FuncB); | |
A.Start(); | |
B.Start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment