Non so perchè ma il compilatore non riesce a trovarmi il metodo newCachedThreadPool()... perchè?
codice:import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; public class RunnableTest { public static void main (String[] args) { PrintTask task1 = new PrintTask ("thread1"); PrintTask task2 = new PrintTask ("thread2"); PrintTask task3 = new PrintTask ("thread3"); System.out.println ("Preparazione dei thread"); ExecutorService threadExecutor = Executors.newCachedThreadPool(); threadExecutor.execute (task1); threadExecutor.execute (task2); threadExecutor.execute (task3); threadExecutor.shutdown(); System.out.println ("Thread iniziati, main finito\n"); } }

Rispondi quotando