0

I have been reading Java Concurrency in Practice. I have seen one statement that says :

Liveness failure such as deadlock, livelock or starvation do not occur in single-threaded programs.

However, let us see an example. If single-threaded app makes I/O request before rendering view, and I/O request takes infinite time conceptually / theoretically. Single-thread app does make forward progress and blocks itself, eventually "nothing good happens".

My question is that is it just a proof that liveness failure may happen in single-threaded programs? Or I may have understood liveness failure wrong?

Farruh Habibullaev
  • 2,342
  • 1
  • 26
  • 33
  • See: https://softwareengineering.stackexchange.com/questions/382350/can-i-produce-a-deadlock-with-a-single-thread-aka-what-is-a-deadlock – Randy Casburn Jan 15 '20 at 05:27
  • 1
    "Liveness failures such as deadlock, livelock, or starvation do not occur..." Doesn't say the same thing as "Liveness failures do not occur..." – Matt Timmermans Jan 15 '20 at 06:09
  • 1
    I think you're misunderstanding the word live, which is the first part of both livelock and liveness. It doesn't mean the same thing in those two. Livelock refers to a specific kind of bug, which can only occur of you have two threads (optionally in different programs that cooperate), liveness refers to the absence of a very large class of bug, including the absence of `while(true) {}`. – arnt Jan 15 '20 at 08:15
  • 1
    "Liveness failure" is a _term of art_. A defect in a single-threaded program can cause it to stop making progress, but we do not call that a "liveness failure." We call it a "hang" or an "infinite loop" etc. We only say "liveness failure" when we're talking about a pathological interaction between multiple threads. – Solomon Slow Jan 15 '20 at 15:24

1 Answers1

1

I get your point. Let us see your example. Because it will take infinite time. So even if there are thousands threads, it is also Liveness failure for your thought. And

liveness is a concurrent application's ability to execute in a timely manner

So it's impossible.

littlebear333
  • 710
  • 2
  • 6
  • 14