-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
When I try to execute several tasks in parallel my code looks ugly.
async {
await {
async {
await {
async {
await {
val it = System.currentTimeMillis()
while (System.currentTimeMillis() - it < 5000);
Log.w("Executing coroutine", "Task1")
}
}
val it = System.currentTimeMillis()
while (System.currentTimeMillis() - it < 5000);
Log.w("Executing coroutine", "Task2")
}
}
val it = System.currentTimeMillis()
while(System.currentTimeMillis() - it < 5000 );
Log.w("Executing coroutine", "Task3")
}
Log.w("Executing coroutine", "All tasks completed")
}
Is any way to make parallel execution looks more elegant?
Something like this
async {
awaitParallel {
val it = System.currentTimeMillis()
while (System.currentTimeMillis() - it < 5000);
Log.w("Executing coroutine", "Task1")
}
awaitParallel {
val it = System.currentTimeMillis()
while (System.currentTimeMillis() - it < 5000);
Log.w("Executing coroutine", "Task2")
}
awaitParallel {
val it = System.currentTimeMillis()
while (System.currentTimeMillis() - it < 5000);
Log.w("Executing coroutine", "Task3")
}
Log.w("Executing coroutine", "All tasks completed")
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels