[Mono-list] problem with Monitor::PulseAll()
Varga Zoltan
vargaz@freemail.hu
Thu, 23 Jan 2003 13:40:17 +0100 (CET)
--0-1804289383-1043325617=:7735
Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-2
Hi All,
It seems Monitor::PulseAll() does not work in the CVS
version of mono.
I attached a test case. Looking at the sources, I found two
strange
things:
- in ves_icall_System_Threading_Monitor_Monitor_wait() , the
mon->waiters_count variable should be decremented before
last_waiters is set, otherwise last_waiters will allways
be FALSE.
- mon->waiters_done is an Event, and the event_signal()
function calls
ResetEvent(). Shouldn't it call SetEvent() instead?
ResetEvent() only
sets a variable, it doesn't signal anything.
bye
Zoltan
--0-1804289383-1043325617=:7735
Content-Type: APPLICATION/octet-stream; name="bug-pulse.cs"
Content-Disposition: attachment; filename="bug-pulse.cs"
using System.Threading;
using System;
class Bug {
static object monitor = new Object ();
private void thread_func () {
Console.WriteLine ("starting thread.");
Thread.Sleep (2000);
Monitor.Enter (monitor);
Monitor.PulseAll (monitor);
Monitor.Exit (monitor);
}
public void test () {
Thread thr = new Thread(new ThreadStart(this.thread_func));
thr.Start();
Monitor.Enter (monitor);
Monitor.Wait (monitor);
Monitor.Exit (monitor);
Console.WriteLine ("done.");
}
static public void Main () {
(new Bug ()).test ();
}
}
--0-1804289383-1043325617=:7735--