(orig post on learn https://forum.dlang.org/post/qzevyxtmksiximcxqgmn@forum.dlang.org)
I just tried:
import std;
void main()
{
writeln("Hello D");
Object obj = null;
synchronized (obj) {
writeln("Synchronized on null");
}
}
output:
Hello D
Error: program killed by signal 11
The following is the usage pattern I want:
void foo(lots of params) {
Object lock = (a particular condition) ? realLock : null;
synchronized(lock) {
// lots of complex code block here
}
}
i.e depending on a a particular condition, the complex code block either need to be sync-protected, or not needed.
Method foo() has lots of params, I try to avoid refactor the inner code block into a separate method.
Since it's not currently supported, can we add such feature? synchronized(null) ==> essentially means NO-OP, instead of NPE?
Thanks.