Last active
January 11, 2019 21:03
-
-
Save prof18/483b80ae8001598495b7dc5b7975b95d to your computer and use it in GitHub Desktop.
This file contains 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
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