Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- suspend fun getFirstImage (firstImageUrl: String, secondImageUrl: String, imageFetcher: ImageFetcher) {
- val images = mutableListOf<Bitmap>()
- val firstJob = launch {
- images.add(imageFetcher.getImageFromUrl(firstImageUrl))
- }
- val secondJob = launch(CommonPool) {
- images.add(imageFetcher.getImageFromUrl(secondImageUrl))
- }
- select<Unit> {
- firstJob.onJoin {
- secondJob.cancel()
- }
- secondJob.onJoin {
- secondJob.cancel()
- }
- }
- }
Add Comment
Please, Sign In to add comment