Some Coding Challenges: Implementing a Lock.

applied.math.coding
2 min readMar 27, 2024

The challenge is to implement a lock in Java by only using synchronized, wait, notify as constructs.

The lock shall work as follows:

var lock = new Lock();

private void doSomething(){
lock.lock();
// no other thread shall be able to go here in the meantime
lock.unlock();
}

A solution written in Java:

--

--

applied.math.coding

I am a Software Developer - Java, Rust, SQL, TypeScript - with strong interest doing research in pure and applied Mathematics.