title: Main Thread used when using coroutine IO Thread in Kotlin
body: <p>I'm trying to get data from server using Volley and HTTPURLConnection. Used coroutine IO Thread to prevent blocking Main thread, but screen stops when doing the job(which means main thread is blocked). </p>
  
  <p>Weird thing is, it works perfectly when doing other jobs using Jsoup and HTTPURLConnection. Only differences I can find is it doesn't use lambda.</p>
  
  <p>What could be the problem? Thanks in advance.</p>
  
  <p>*Edit1: I used suspend and withContext, but I found that removing those don't solve the problem.</p>
  
  <p><strong>Code of ConDetailActivity.kt</strong></p>
  
  <pre><code>    val scope = CoroutineScope(Dispatchers.IO)
      private fun initialize(context: Context,idx:String) = scope.launch{
          try{
              ConCrawler.getConData(context,idx) {data -&gt;
                  CoroutineScope(Dispatchers.Main).launch { adapter.addData(data.imgDataList) }
                  progressbar.visibility = View.INVISIBLE
              }
  
          }catch(e:Exception){
              e.printStackTrace()
          }
      }
  </code></pre>
  
  <p><strong>Code of object ConCrawler</strong></p>
  
  <pre><code>    suspend fun getConData(context: Context, idx: String, returnConData: (condata: ConDataforReturn) -&gt; Unit) = withContext(Dispatchers.Default) {
          val params = HashMap&lt;String, String&gt;()
          val cd = arrayListOf&lt;ConImgData?&gt;()
          var title = ""
          params.put("package_idx", idx)
          VolleyRequest(context, params, "https://dccon.dcinside.com/index/package_detail") { response -&gt;
              val answer = JSONObject(response)
              var json = answer.getJSONArray("detail")
              title = answer.getJSONObject("info").getString("title")
              for (i in 0..(json.length() - 1)) {
                  val v = json.getJSONObject(i)
                  cd.add(ConImgData(v.getString("title"), v.getString("ext"), runBlocking { getBitmapFromURL("https://dcimg5.dcinside.com/dccon.php?no=" + v.getString("path")) }, v.getString("path")))
              }
              returnConData(ConDataforReturn(title, cd))
          }
      }
  
      fun VolleyRequest(context: Context, params: HashMap&lt;String, String&gt;, link: String, success: (response: String) -&gt; Unit) {
          val queue = Volley.newRequestQueue(context)
          val stringRequest = object : StringRequest(Method.POST, link,
              Response.Listener&lt;String&gt; { response -&gt;
                  Log.e("response", response.toString())
                  success(response)
              },
              Response.ErrorListener { error -&gt;
                  error.printStackTrace()
              }) {
              override fun getHeaders(): MutableMap&lt;String, String&gt; {
                  val headers = mutableMapOf&lt;String, String&gt;()
                  /*unused headers
                  headers.put("user-agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36")
                  headers.put("origin","https://dccon.dcinside.com")
                  headers.put("referer","https://dccon.dcinside.com")
                  headers.put("content-type","multipart/form-data")
                   */
                  headers.put("x-requested-with", "XMLHttpRequest")
                  return headers
              }
  
              override fun getParams(): MutableMap&lt;String, String&gt; {
                  return params
              }
  
          }
          stringRequest.setShouldCache(false)
          queue.add(stringRequest)
      }
      suspend fun getBitmapFromURL(src: String): Bitmap? = withContext(Dispatchers.Default) {
          try {
              val url = URL(src)
              val connection: HttpURLConnection = url.openConnection() as HttpURLConnection
              connection.setRequestProperty("Referer", "https://dccon.dcinside.com")
              connection.setRequestProperty("Sec-Fetch-Mode", "no-cors")
              connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36")
              connection.setDoInput(true)
              connection.connect()
              val input: InputStream = connection.getInputStream()
              BitmapFactory.decodeStream(input)
          } catch (e: Exception) { // Log exception
              e.printStackTrace()
              null
          }
      }
  </code></pre>