I have an interface method boolean right(), if it isn't "answering" in a second, it should return false.
Yes, this is possible with e.g. java.util.concurrent.Future<V> (the standard interface to represents the result of an asynchronous computation of type V), combined with the method get(long timeout, TimeUnit unit). The method may throw TimeoutException, among other exceptions, but otherwise returns the computed result on normal execution.
In this case you want a Future<Boolean>, with get(1, TimeUnit.SECONDS) within a try-catch block, handling TimeOutException per your specification.
Available concrete implementations are FutureTask<V> and SwingWorker<T,V>. If this is within the context of Swing application, then you'd want to use the latter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With