Sobes.tech
Senior
47

դասարան Task { մասնավոր static int հաշվիչ = 0; հանրային static void main(String[] args) throws Exception { var thread1 = new Thread(() -> ավելացնել()); var thread2 = new Thread(() -> ավելացնել()); thread1.start(); thread2.start(); thread1.join(); thread2.join(); System.out.println(հաշվիչ); } մասնավոր static void ավելացնել() { համար (int i = 0; i < 5000; i++) { հաշվիչ++; } } }

Ընկերությունները, որտեղ հարցրել են
сербская компания