How I Fell in Kotlin’s RunBlocking Deadlock Trap, and How You Can Avoid It
<p>It’s a super easy way to start new coroutines. Calling a suspending function like <code>delay</code> from a plain old function would normally give you an angry red compilation error. But wrap it with <code>runBlocking</code>, and suddenly you’re free not only to call all the suspending functions you like, but also to use coroutine builders like <code>launch</code> and <code>async</code>.</p>
<p>Using <code>runBlocking</code> in the main function like this is no problem. But when was the last time you actually added code to the main entry point of a real production system? When you’re working with coroutines, you’re more likely to be deep within your app’s code, and that’s where things get more complicated.</p>
<p><a href="https://betterprogramming.pub/how-i-fell-in-kotlins-runblocking-deadlock-trap-and-how-you-can-avoid-it-db9e7c4909f1"><strong>Click Here</strong></a></p>