Sobes.tech
Senior

classe Tâche { privé statique int compteur = 0; public static void main(String[] args) throws Exception { var thread1 = new Thread(() -> augmenter()); var thread2 = new Thread(() -> augmenter()); thread1.start(); thread2.start(); thread1.join(); thread2.join(); System.out.println(compteur); } privé static void augmenter() { pour (int i = 0; i < 5000; i++) { compteur++; } } }