Deadlock in Java
Deadlock is part of Java concurrency. A thread is a path of work inside a process. Create with Thread or Runnable, then call start() — not run(). run() only runs on the same thread.
For Deadlock: if two threads share data, synchronize or the result can be wrong. sleep pauses. join waits for another thread to finish. daemon threads die when all user threads finish.
Deadlock deadlock: two threads wait for each other’s lock forever. Avoid by locking in the same order. Don’t guess thread order — it can change every run.
Let's take this on the board with one tiny Main class — no extra files. Deadlock in Java — output: 2000. Two threads each inc 1000 times. synchronized keeps the count exact — without it, you can get less than 2000. Start from main, go line by line, and stop at each print. That output is the proof for Deadlock.
Define deadlock with a 2-lock A/B story.