Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun <T> executeTimeout(executor: Executor, timeoutMs: Long, block: () -> T): T? {
- var t: T? = null
- val latch = CountDownLatch(1)
- executor.execute { t = block(); latch.countDown() }
- latch.await(timeoutMs, TimeUnit.MILLISECONDS)
- return t
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement