假设有三个可运行任务,task1,task2,task3。如何在具有2个固定线程的线程池中运行它们? A: newThread(task1).start();newThread(task2).start();newThread(task3).start(); B: ExecutorServiceexecutor=Executors.newFixedThreadPool(3);executor.execute(task1);executor.execute(task2);executor.execute(task3); C: ExecutorServiceexecutor=Executors.newFixedThreadPool(2);executor.execute(task1);executor.execute(task2);executor.execute(task3); D: ExecutorServiceexecutor=Executors.newFixedThreadPool(1);executor.execute(task1);executor.execute(task2);executor.execute(task3);
假设有三个可运行任务,task1,task2,task3。如何在具有2个固定线程的线程池中运行它们? A: newThread(task1).start();newThread(task2).start();newThread(task3).start(); B: ExecutorServiceexecutor=Executors.newFixedThreadPool(3);executor.execute(task1);executor.execute(task2);executor.execute(task3); C: ExecutorServiceexecutor=Executors.newFixedThreadPool(2);executor.execute(task1);executor.execute(task2);executor.execute(task3); D: ExecutorServiceexecutor=Executors.newFixedThreadPool(1);executor.execute(task1);executor.execute(task2);executor.execute(task3);
运行下列程序,会产生什么结果?()1)publicclassExercises3_1extendsThreadimplementsrunable{2)publicvoidrun(){3)System.out.println("thisisrun()");4)}5)publicstaticvoidmain(Stringargs[]){6)Threadt=newThread(newExercises3_1());7)t.start();8)}9)}
运行下列程序,会产生什么结果?()1)publicclassExercises3_1extendsThreadimplementsrunable{2)publicvoidrun(){3)System.out.println("thisisrun()");4)}5)publicstaticvoidmain(Stringargs[]){6)Threadt=newThread(newExercises3_1());7)t.start();8)}9)}