-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScheduling.cs
38 lines (37 loc) · 956 Bytes
/
Scheduling.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
namespace tpfinal
{
public class Scheduling
{
private List<Proceso> procesos = new List<Proceso>();
private object locker = new object();
public Scheduling(List<Proceso> procesos)
{
this.procesos = procesos;
}
public Proceso getProceso()
{
String ThreadName = Thread.CurrentThread.Name;
Console.WriteLine("{0} using C-sharpcorner.com", ThreadName);
Monitor.Enter(locker);
try
{
if (this.procesos.Count > 0){
var ele = this.procesos[0];
this.procesos.RemoveAt(0);
return ele;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Monitor.Exit(locker);
Console.WriteLine("{0} releasing C-sharpcorner.com", ThreadName);
}
return null;
}
}
}