https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

asad.awadia

11/24/2019, 3:55 PM
does wrapping blocking calls
withContext(<http://Dispatchers.IO|Dispatchers.IO>)
stop my threads from getting 'blocked'?
s

streetsofboston

11/24/2019, 4:24 PM
No. It does not prevent threads from getting blocked. It does prevent the calling thread from being blocked (instead, the calling thread will be suspended) The Dispatchers.IO dispatcher, however, is designed to handle blocking threads (its pool is large and tailored for running code that may get blocked (often) - and do nothing but wait)
a

asad.awadia

11/24/2019, 5:23 PM
I thought it had only 64 threads
l

louiscad

11/24/2019, 11:28 PM
ONLY? 64 threads is a lot! You can still change it though.
That's the upper bound BTW, it won't create 64 threads if you only need 13.
a

asad.awadia

11/24/2019, 11:29 PM
Maybe client side 64 is a lot
I m looking at it from server side
l

louiscad

11/24/2019, 11:32 PM
On server side, you should use non blocking I/O whenever possible so you don't need
<http://Dispatchers.IO|Dispatchers.IO>
unless really needed for filesystem I/O.
6 Views