Somehow I missed this, but Java already has pattern matching for switch as a standard feature since Java 21. Pattern matching itself simplifies type checks, and also allows you to cast an object in a ...
3. If the lock is held by the same thread: The thread can re-enter. This is called reentrancy, and it prevents a thread from deadlocking itself. When the owning thread exits the block (either by ...