public static void AddTask(Runnable r) { lock (tasks) { tasks.AddFirst(r); Monitor.Pulse(tasks); } }
public void AddTask(Runnable task, long waitsecds) { lock (ilock) { long timestamp = waitsecds + elapse; LinkedList<Runnable> tasklist; if (tasks.TryGetValue(timestamp, out tasklist)) { tasklist.AddLast(task); } else { tasklist = new LinkedList<Runnable>(); tasklist.AddLast(task); tasks.Add(timestamp, tasklist); } } }
public static void AddTimerTask(Runnable task, long waitsecds) { instance.AddTask(task, waitsecds); }