Skip to content

Instantly share code, notes, and snippets.

@csadilek
Last active August 29, 2015 14:00
Show Gist options
  • Save csadilek/4b92f06d6bfec5b22270 to your computer and use it in GitHub Desktop.
Save csadilek/4b92f06d6bfec5b22270 to your computer and use it in GitHub Desktop.
@Service
public class LongRunningServiceImpl implements LongRunningService {
@Override
public CallableFuture<String> someLongRunningTask() {
final CallableFuture<String> future =
CallableFutureFactory.get().createFuture(String.class);
// Start some asynchronous, potentially slow computation
SomeSlowStringComputation slow = new SomeSlowStringComputation();
slow.start(new ResultCallback<String>() {
public void onResult(String result) {
future.setValue(result);
}
});
return future;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment