[Issue 18277] New: synchronized statement with comma operator ignores first arguments
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 22 11:47:05 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18277
Issue ID: 18277
Summary: synchronized statement with comma operator ignores
first arguments
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: simen.kjaras at gmail.com
According to TDPL[1], synchronized (a, b) should should lock both a and b. This
does not happen:
import std.stdio;
import core.thread;
class C {}
class MyThread1 : Thread {
C c, d;
this(C c, C d) {
this.c = c;
this.d = d;
super(&run);
}
void run() {
synchronized(c, d) {
writeln("Thread sleeping...");
Thread.sleep(5.dur!"seconds");
writeln("Thread woke up");
}
}
}
unittest {
C c = new C;
C d = new C;
auto derived = new MyThread1(c, d).start();
Thread.sleep(2.dur!"seconds");
synchronized(c) {
writeln("c is not synchronized");
}
synchronized(d) {
writeln("d is synchronized");
}
}
Expected output:
Thread sleeping...
Thread woke up
c is not synchronized
d is synchronized
Actual output:
Thread sleeping...
c is not synchronized
Thread woke up
d is synchronized
[1]: http://www.informit.com/articles/article.aspx?p=1609144&seqNum=15
--
More information about the Digitalmars-d-bugs
mailing list