On Thu, 9 Jun 2022 21:11:55 GMT, David M. Lloyd <d...@openjdk.java.net> wrote:
>> https://github.com/openjdk/jdk/blob/bc28baeba9360991e9b7575e1fbe178d873ccfc1/src/java.base/share/classes/jdk/internal/misc/Signal.java#L177-L178 >> >> Instead of separate Hashtable.get/remove calls we can just use value >> returned by `remove`, >> It results in cleaner and a bit faster code. > > src/java.base/share/classes/jdk/internal/misc/Signal.java line 180: > >> 178: if (newH == 2) { >> 179: handlers.put(sig, handler); >> 180: } > > If you made this change instead: > > Suggestion: > > Signal.Handler oldHandler; > if (newH == 2) { > oldHandler = handlers.replace(sig, handler); > } else { > oldHandler = handlers.remove(sig); > } > > > Wouldn't you be able to remove the entire `synchronized` block? Hello David, I suspect you mean `handlers.put(sig, handler)` and not `handlers.replace(...)`? And yes, I think what you suggest will help remove the synchronized block here. ------------- PR: https://git.openjdk.org/jdk/pull/9100