Java – examples / illustrations of wait free and lock free algorithms

I have read that waiting for free causes all threads to complete independently, and no locking ensures that the program is completed as a whole I don't understand. Anyone can give an example (Java) to illustrate this

Edit: does no lock mean that the program has no deadlock?

Solution

If a program is unlocked, it basically means that at least one thread can be guaranteed to run at any time If a program deadlocks, its thread (and therefore the entire program) cannot proceed - we can say that it is not unlocked As the lockless program has guaranteed progress, it is guaranteed to be completed (assuming limited execution and no exceptions)

No waiting is a stronger condition, which means that each thread is guaranteed to execute in any time period, regardless of the time / order of thread execution; So we can say that threads complete independently All programs waiting for free are unlocked

I don't know any java examples that illustrate this, but I can tell you that lockless / wait free programs are usually implemented using low-level primitives (such as CAS instructions)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>