- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
// same as Callable but without exception
public interface Executable<T>
{
public T call();
}
/*В другом классе: методы для конверсии туда-сюда */
public Callable<T> toCallable(final Executable<T> ex){
return new Callable<T>(){
public T call() throws Exception{
return ex.call();
}
};
}
public Executable<T> toExecutable(final Callable<T> c)
{
return new Executable<T>(){
public T call(){
try{
return c.call();
}catch (Exception e){
throw new RuntimeException(e);
}
}
};
}