Skip to content

Instantly share code, notes, and snippets.

@vigneshwaranr
Created February 14, 2021 07:14
Show Gist options
  • Save vigneshwaranr/e0fbc9acb6ecba529192308924b6d37b to your computer and use it in GitHub Desktop.
Save vigneshwaranr/e0fbc9acb6ecba529192308924b6d37b to your computer and use it in GitHub Desktop.
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
trait AsyncJob {
def execute(): Future[Boolean]
}
class MyLongRunningJob(asyncJob: AsyncJob) extends Runnable {
override def run(): Unit = {
val result = Await.result(asyncJob.execute(), Duration.Inf)
if (!result) {
throw new RuntimeException("What the hell!")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment