Last active
April 12, 2016 06:43
-
-
Save tpdns90321/62602e211d7ee29fdca0c92b0bef7b7a 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 FuncAStop{ | |
class Program{ | |
static Thread A; | |
static Thread B; | |
static void FuncA(){ | |
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.Abort(); | |
} | |
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