public interface Poller<T>
Callable
instance provided by the user. Use
when you need to put something in the background (e.g. a remote invocation)
and wait for the result, e.g.
Poller<Result> poller = ... final long id = remoteService.execute(); // do something remotely Future<Result> future = poller.poll(new Callable<Result> { public Object call() { // Look for the result (null if not ready) return remoteService.get(id); } }); Result result = future.get(1000L, TimeUnit.MILLSECONDS);
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.Future<T> |
poll(java.util.concurrent.Callable<T> callable)
Use the callable provided to poll for a non-null result.
|
java.util.concurrent.Future<T> poll(java.util.concurrent.Callable<T> callable) throws java.lang.Exception
callable
- a Callable
to use to retrieve a resultjava.lang.Exception
- allows for checked exceptions