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
2024-05-13 11:33:30.198 9900-9972 System.out A | |
2024-05-13 11:33:30.199 9900-9972 System.out С | |
2024-05-13 11:33:31.203 9900-9973 System.out B |
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
val myScope: CoroutineScope = CoroutineScope(context = Job()) | |
myScope.launch { | |
delay(500L) | |
println("A") | |
launch { | |
delay(1000L) | |
println("B") | |
} |
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
val myScope: CoroutineScope = CoroutineScope(context = Job()) |
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
2024-05-13 10:43:21.233 32562-32614 System.out A | |
2024-05-13 10:43:21.336 32562-32613 System.out C | |
2024-05-13 10:43:22.237 32562-32613 System.out B | |
2024-05-13 10:43:22.238 32562-32613 System.out D |
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
val myScope: CoroutineScope = CoroutineScope(context = Job()) | |
myScope.launch { | |
delay(500L) | |
println("A") | |
coroutineScope { | |
launch { | |
delay(1000L) | |
println("B") |
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
class MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
CoroutinestrickyquestionsTheme { | |
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { |
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
class MainActivity : AppCompatActivity() { | |
private lateinit var binding: ActivityMainBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) |
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
internal suspend fun downloadUserData(): String { | |
withContext(Dispatchers.IO) { | |
println("downloadUserData started on ${Thread.currentThread().name}") | |
val result1 = async { receiveAdditionalUserData(taskNumber = 1) } | |
val result2 = async { receiveAdditionalUserData(taskNumber = 2) } | |
println(result1.await()) | |
println(result2.await()) |
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
2023-12-05 20:33:43.418 27802-27834 System.out downloadUserData started on DefaultDispatcher-worker-1 | |
2023-12-05 20:33:43.428 27802-27836 System.out receiveAdditionalUserData number: 1 started on DefaultDispatcher-worker-3 | |
2023-12-05 20:33:43.432 27802-27835 System.out receiveAdditionalUserData number: 2 started on DefaultDispatcher-worker-2 | |
2023-12-05 20:33:43.439 27802-27836 System.out receiveAdditionalUserData number: 1 finished on DefaultDispatcher-worker-3 | |
2023-12-05 20:33:43.441 27802-27839 System.out receiveAdditionalUserData number: 1, background work on Thread-7 | |
2023-12-05 20:33:43.444 27802-27835 System.out receiveAdditionalUserData number: 2 finished on DefaultDispatcher-worker-2 | |
2023-12-05 20:33:43.451 27802-27840 System.out receiveAdditionalUserData number: 2, background work on Thread-8 | |
2023-12-05 20:33:44.453 27802-27834 System.out AdditionalUserData 1 received | |
2023-12-05 20:33:44.456 27802-2 |
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
... | |
2023-11-26 22:58:32.081 Coroutine count: 999998 | |
2023-11-26 22:58:32.081 Coroutine count: 999999 | |
2023-11-26 22:58:32.082 Coroutine count: 1000000 |
NewerOlder