Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Threading;
- namespace MultiThreadedJoins
- {
- class Program
- {
- static void Main(string[] args)
- {
- int timeout = 1000;
- List<Thread> tlist = new List<Thread>();
- for (int i = 0; i < 10; i++)
- {
- Thread t = new Thread(MethodName);
- tlist.Add(t);
- t.Start(timeout);
- }
- foreach (var t in tlist)
- {
- bool finished = t.Join(timeout);
- t.Abort();
- Console.WriteLine(finished.ToString());
- }
- Console.Read();
- }
- private static void MethodName(object data)
- {
- Thread.Sleep(10000);
- Console.WriteLine("fish");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement