<p>There are indeed universal construction schemes for lock-free or even wait-free algorithms. For example:</p>

<ul>
<li><a href="https://www.researchgate.net/publication/221643573_A_Methodology_for_Implementing_Highly_Concurrent_Data_Structures" rel="nofollow noreferrer">A Methodology for Implementing Highly Concurrent Data Structures</a></li>
<li><a href="https://www.researchgate.net/publication/221257088_A_highly-efficient_wait-free_universal_construction" rel="nofollow noreferrer">A highly-efficient wait-free universal construction</a></li>
<li><a href="https://arxiv.org/abs/1911.01676" rel="nofollow noreferrer">A Wait-Free Universal Construct for Large Objects</a></li>
</ul>

<p>However, these are usually more interesting from a theoretical perspective rather than a practical one. In practice, specialized lock-free algorithms usually perform better than those derived from these universal constructions.</p>

<p>If you are interesting in the area of lock-free programming I would recommend to start with the book <a href="https://rads.stackoverflow.com/amzn/click/com/0123973376" rel="nofollow noreferrer" rel="nofollow noreferrer">The Art of Multiprocessor Programming</a>.</p>
a generic lock-free synchronization
<p>The implementation of lock-free data structures is sometimes not easy to implement. The following approach may seem generic and easy but I think here we have some issues:</p>

<pre><code>private AtomicBoolean lock = new AtomicBoolean(false);

    public void func(...) {
        while !lock.compareAndSet(false,true);
        // Some code goes here...
        ...
        ...
        ...
        lock.set(false); 
    }
}
</code></pre>

<p>I think The code above is not really "lock-free", as it locks the awaiting Threads in the while loop in busy-wait mode.</p>

<p>Therefore, the code is suitable only when the "right" lock-free synchronization is impossible.</p>

<p>My question is - Is it possible to implement a generic lock-free with some different approach and it will works so threads will not be in blocked(like synchronized) or busy mode state and the code will run parallel, so we improve performance?</p>

<p>My aim is to keep the threads running. I know that if the code is long, it is better to use the synchronized mechanism instead of the lock-free implementation, so let's assume we are talking on short code.</p>

<p>For example, below is example of Linkedlist which I think is good approach but it not generic for common data stractures. 
if we are used here with AtomicBoolean as I show above, it will not be realy "lock-free".</p>

<pre><code>public class LinkedList&lt;T&gt; {

    private AtomicReference&lt;Link&lt;T&gt;&gt; head = new AtomicReference(null);

    public  void add(T data) {
      Link&lt;T&gt; localHead;
      Link&lt;T&gt; newHead = new Link&lt;&gt;(null, data);

      do {
        localHead = head.get();
        newHead.next = localHead;        
      } while (!head.compareAndSet(localHead, newHead));
    }
}
</code></pre>