Can we create deadlock without thread in java? This question was asked in java interview can anybody answer this.
Asked
Active
Viewed 467 times
-4
-
You can't do anything without a thread in Java. Running `java` creates a thread. The "main" thread. – Stephen C Nov 05 '18 at 06:08
1 Answers
2
It's not possible to run code without at least one thread. A single thread can block itself in some cases eg attempting to upgrade a read lock to a write lock.
When a thread resource starves itself, it is called a livelock
I added more detail on livelocks in Java here Is it possible for a thread to Deadlock itself?
It is also possible to create a deadlock without creating an additional thread e.g. the finalizer thread and the main thread could deadlock each other.

Peter Lawrey
- 525,659
- 79
- 751
- 1,130