码迷,mamicode.com
首页 > 其他好文 > 详细

使用Guava适配不同的callback

时间:2017-10-03 16:25:42      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:word   was   turn   number   err   exec   bsp   guava   nbsp   

  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

标签:word   was   turn   number   err   exec   bsp   guava   nbsp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!