import java.util.ArrayList; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import java.util.concurrent.locks.*; public class workerClass implements Runnable{ @Override public void run(){ for (int i = 0; i <=5; i++){ System.out.println(i); try { Thread.sleep(1000); } catch (InterruptedException e) {} } } public static void main(String[] args) { Thread trad1 = new Thread(new workerClass()); Thread trad2 = new Thread(new workerClass()); trad1.start(); try { trad1.join(); } catch (InterruptedException e) {} trad2.start(); // Thread[] threads = new Thread[5]; // for(int i = 0; i < 5; i++){ // threads[i] = new Thread(new workerClass()); // threads[i].start(); // } // try{ // for(int i = 0; i < 5; i++){ // threads[i].join(); // } // } catch(InterruptedException e){ // e.printStackTrace(); // // h?ndtere exception ... // } // ArrayList numbs = new ArrayList(); // numbs.add(1); // numbs.add(2); // numbs.add(3); // numbs.add(4); // Consumer metode2 = (val) -> { System.out.println(val); }; // System.out.println(metode2.hashCode()); // numbs.forEach(metode2); // Londition cond = laas.newCondition(); // System.out.println(laas.getClass()); // System.out.println(cond.getClass()); // Thread traad = new Thread(new workerClass()); // try { // Thread.sleep(1000);//"sover" et sekund // } catch (InterruptedException e) { // e.printStackTrace(); // // h?ndtere exception // }ock laas = new ReentrantLock(); } }