Code example for FutureTask

0
  protected WebDriverHandler(Session session) {
    this.session = session;
  } 
 
  public final ResultType handle() throws Exception { 
    FutureTask<ResultType> future = new FutureTask<ResultType>(this);
    try { 
      return getSession().execute(future);
    } catch (ExecutionException e) {
      Throwable cause = e.getCause();
      if (cause instanceof Exception)
        throw (Exception) cause;
      throw e;
    } 
  } 
 
  public SessionId getSessionId() { 
    return session.getSessionId();
  }