Guest User

Untitled

a guest
Jan 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. suspend fun getFirstImage (firstImageUrl: String, secondImageUrl: String, imageFetcher: ImageFetcher) {
  2. val images = mutableListOf<Bitmap>()
  3. val firstJob = launch {
  4. images.add(imageFetcher.getImageFromUrl(firstImageUrl))
  5. }
  6. val secondJob = launch(CommonPool) {
  7. images.add(imageFetcher.getImageFromUrl(secondImageUrl))
  8. }
  9.  
  10. select<Unit> {
  11. firstJob.onJoin {
  12. secondJob.cancel()
  13. }
  14. secondJob.onJoin {
  15. secondJob.cancel()
  16. }
  17. }
  18. }
Add Comment
Please, Sign In to add comment