is it possible synchronized(null) ? i.e NO-OP
mw
mingwu at gmail.com
Fri Aug 26 17:13:09 UTC 2022
Hi,
I haven't tried, but can I do:
```
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.
So my question: is it possible synchronized(null)? essentially
means NO-OP.
If it's not currently supported, can we add such feature?
Thank.
More information about the Digitalmars-d-learn
mailing list