I have a Future , and I want to find out what kind of condition. I meant code like:
try { // Is that a good idea? Counting on exceptions looks weird. future.get(0, TimeUnit.MICROSECONDS); this.status = DONE; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Throwables.propagate(e); } catch (ExecutionException e) { this.status = FAILED; } catch (TimeoutException e) { this.status = RUNNING; } catch (CancellationException e) { this.status = CANCELED; }
It looks like FutureTask will try to hold the lock, and if it can get the lock, the status of the Future will be checked. So this is a good idea.
Are there any pitfalls that I'm missing here?
Hbase source share