Skip to content

Instantly share code, notes, and snippets.

@prof18
Last active January 11, 2019 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prof18/483b80ae8001598495b7dc5b7975b95d to your computer and use it in GitHub Desktop.
Save prof18/483b80ae8001598495b7dc5b7975b95d to your computer and use it in GitHub Desktop.
fun execute(url: String) {
Executors.newSingleThreadExecutor().submit{
val service = Executors.newFixedThreadPool(2)
val f1 = service.submit<String>(XMLFetcher(url))
try {
val rssFeed = f1.get()
val f2 = service.submit(XMLParser(rssFeed))
onComplete.onTaskCompleted(f2.get())
} catch (e: Exception) {
onComplete.onError(e)
} finally {
service.shutdown()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment