本帖最后由 zl78365336 于 2013-12-9 17:50 编辑
ServiceWindow类中,老师讲说,while语句放在switch外面效率低,while语句放在switch里面更高效,要怎么放呢?
- public void start(){
- Executors.newSingleThreadExecutor().execute(new Runnable(){
- public void run(){
- while(true){
- switch(type){
- case COMMON:
- commonService();
- break;
- case EXPRESS:
- expressService();
- break;
- case VIP:
- vipService();
- break;
- }
- }
- }
- });
- }
复制代码
|