假设有三个可运行任务,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);
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);
举一反三
- 见PDF Task 1, Task 2, Task 3
- Task是Executor上的工作单元,运行于下面哪个组件上?
- 下列关于Storm框架,描述正确的有? A: worker:每个worker进程都属于一个特定的Topology B: executor:executor是产生于worker进程内部的线程 C: task:实际的数据处理由task完成 D: 在Topology的生命周期中,每个组件的task数目是不会发生变化的,而executor的数目却不一定
- 中国大学MOOC:Task是Executor上的工作单元,运行于下面哪个组件上?
- task运行在下面哪里个选项中Executor上的工作单元() A: driver B: master C: worker D: cluster