Exemple #1
0
 public static void Viewer(int id, Videos videos)
 {
     id++;
     Console.WriteLine($"Viewer {id} has been born");
     if (sem2.Wait(3000))
     {
         int video = videos.Watch;
         Console.WriteLine($"Viewer {id} is currently watching video {video+1}");
         Thread.Sleep(2000);
         Console.WriteLine($"Viewer {id} has finished watching video {video+1}");
         videos.Finish(video);
         sem2.Release();
     }
     else
     {
         Console.WriteLine($"Viewer {id} left unhappy"); //happyn't
     }
 }