Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- namespace RandomizacijaKarta
- {
- class Program
- {
- public static Random r = new Random();
- public static void ImaNema()
- {
- int ima = r.Next(0, 2);
- if (ima == 1)
- {
- Console.WriteLine("{0} ima kartu", Thread.CurrentThread.Name);
- }
- else
- {
- Console.WriteLine("{0} nema kartu", Thread.CurrentThread.Name);
- }
- }
- static void Main(string[] args)
- {
- Thread[] threads = new Thread[10];
- for(int i = 0; i < threads.Length; i++)
- {
- threads[i] = new Thread(ImaNema);
- threads[i].Name = string.Format("Putnik #{0}", i+1);
- threads[i].Start();
- }
- for (int i = 0; i < threads.Length; i++)
- {
- threads[i].Join();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement