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;
- namespace PhilosopherServer
- {
- class Program
- {
- const int kNumPhilosophers = 5;
- static String kFork = "Fork";
- static void Main(string[] args)
- {
- Semaphore[] forks = new Semaphore[kNumPhilosophers];
- for (int i = 0; i < kNumPhilosophers; i++)
- {
- String ii = i.ToString();
- String forkName = kFork + ii;
- Console.WriteLine(forkName);
- forks[i] = new Semaphore(5, 5, forkName);
- }
- Semaphore kek = new Semaphore(5, 5);
- if (Semaphore.TryOpenExisting("Fork1", out kek))
- {
- Console.WriteLine("Success");
- }
- else
- {
- Console.WriteLine("Bad job");
- }
- while(true)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement