title: Difference between ExecutionContext.global and main Thread
body: <p>I have following code:</p>
  
  <pre><code>object KafkaApi {
  
    private implicit val main: ExecutionContextExecutor = ExecutionContext.global
    private val workers = ExecutionContext.fromExecutor(Executors.newCachedThreadPool())
  
    def main(args: Array[String]) {
  
      foo.unsafeRunAsync(_ =&gt; ())
      //foo.unsafeRunSync()
      println("Hello")
  
  
    }
  
    def foo: IO[Unit] =
      for {
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
        _ &lt;- IO.shift(workers)
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
        _ &lt;- IO.shift(main)
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
        _ &lt;- IO {
          println(Thread.currentThread().getName)
        }
      } yield ()
  }
  </code></pre>
  
  <p>and the output is:</p>
  
  <pre><code>main
  Hello
  pool-1-thread-1
  pool-1-thread-1
  pool-1-thread-1
  scala-execution-context-global-14
  scala-execution-context-global-14
  scala-execution-context-global-14
  </code></pre>
  
  <p>What is the difference between <strong>main</strong> and <strong>scala-execution-context-global-14</strong>? </p>
  
  <p>If these two are different, how to get the main thread back?  </p>