I\'ve read that wait-free causes all threads to finish independently and lock-free ensures the program as a whole completes. I couldn\'t quite get it. Can anyone give an example
From the weaker to the stronger condition:
A method is lock-free if it guarantees that infinitely often some method call finishes in a finite number of steps.
A method is wait-free if it guarantees that every call finishes its execution in a finite number of steps.
Clearly, any wait-free method implementation is also lock-free, but not vice versa. Lock-free algorithms admit the possibility that some threads could starve.
However, from a "Practical Perspective" there are many situations in which starvation, while possible, is extremely unlikely, so a fast lock-free algorithm may be more attractive than a slower wait-free algorithm.
NOTE: An even stronger property it is called "bounded wait-free" which means: there is a bound on the number of steps a method call can take.