On Monday, 9 April 2018 at 22:28:45 UTC, Jonathan wrote:
I am totally lost on why this is happening.
I stripped the code down to what appears to be the most minimal
code that still causes the problem.
---
import core.sync.mutex;
import core.thread;
import std.stdio;
__gshared Mutex m;//__gshared just for testing (;
void thread1() {
foreach (i;0..8) {
synchronized(m) {
writeln("a1-",i);
}
writeln("a2-",i);
}
}
void thread2() {
foreach (i;0..8) {
synchronized(m) {
writeln("b1-",i);
}
writeln("b2-",i);
}
}
void main() {
m = new Mutex();
new Thread(&thread1).start;
new Thread(&thread2).start;
}
---
The beginning of the output for this code is:
a1-0
a2-0
a2-0
b1-0
b2-0
b2-0
a1-1
a2-1
a2-1
Why is the "a2" and "b2" writeln being repeated?!
I don't know, but I can't reproduce either with dmd or ldc. What
was your compilation line?