Created
February 14, 2021 07:14
-
-
Save vigneshwaranr/e0fbc9acb6ecba529192308924b6d37b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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