各位大牛,小弟现在遇到一个问题,就是使用多线程调用一个耗时的方法,如何同步?代码大体如下: 
-   final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10);   
 - final BusinessService service = new BusinessService();   
 - for(int i = 0; i < 10; i++)  
 - {  
 -     scheduler.scheduleWithFixedDelay(new Runnable(){  
 -         @Override  
 -         public void run() {  
 -             service.handleBusiness();  
 -         }  
 -           
 -     }, i, 5, TimeUnit.MINUTES);  
 - }  
 
这个时候,如果在handleBusiness()方法上加上
Java代码:  
synchronized  
,其它线程就进不了这个方法,因为这个方法需要耗时5分钟左右,大家帮忙想想有啥好的解决办法,能让所有线程不等待,就可以调用这个方法又保持原子操作.
解决方法:handleBusiness()写成线程安全的就好了。