• 2022-06-07
    假设有三个可运行任务,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);