Sobes.tech
Senior
51

κλάση Task { ιδιωτική στατική int μετρητής = 0; δημόσια στατική 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++) { μετρητής++; } } }

Εταιρείες όπου ρωτήθηκαν
сербская компания