package com.example; import com.example.util.ThreadUtils; public class LiveLock { private static boolean thread1WantsToPass = true; private static boolean thread2WantsToPass = true; public static void main(String[] args) { Thread thread1 = new Thread( () -> { while (thread1WantsToPass) { System.out.println("Поток 1: Я уступаю дорогу Потоку 2..."); ThreadUtils.sleep(100); } System.out.println("Поток 1 прошел!"); }); Thread thread2 = new Thread( () -> { while (thread2WantsToPass) { System.out.println("Поток 2: Я уступаю дорогу Потоку 1..."); ThreadUtils.sleep(100); } System.out.println("Поток 2 прошел!"); }); thread1.start(); thread2.start(); } }