首页 > 其他 > 详细

使用Guava适配不同的callback

时间:2017-10-03 16:15:36      阅读:223      评论:0      收藏:0      [点我收藏+]
  1. Cache<Key,Value> cache =CacheBuilder.newBuilder()  
  2.     .maximumSize(1000)  
  3.     .build();// look Ma, no CacheLoader  
  4. ...  
  5. try{  
  6.     // If the key wasn‘t in the "easy to compute" group, we need to  
  7.     // do things the hard way.  
  8.     cache.get(key,newCallable<Value>(){  
  9.         @Override  
  10.         publicValue call()throwsAnyException{  
  11.             return doThingsTheHardWay(key);  
  12.         }  
  13.     });  
  14. }catch(ExecutionException e){  
  15.     thrownewOtherException(e.getCause());  
  16. }  

使用Guava适配不同的callback

原文:http://www.cnblogs.com/panxuejun/p/7623835.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!