package lr12; import java.time.LocalTime; public class e1 { public static void main(String[] args) { Runnable task = () -> { long endTime = System.currentTimeMillis() + 10_000; while (System.currentTimeMillis() < endTime) { System.out.println( Thread.currentThread().getName() + " : " + LocalTime.now()); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }; Thread t1 = new Thread(task, "Thread-1"); Thread t2 = new Thread(task, "Thread-2"); t1.start(); t2.start(); } }