# Coroutine GlobalScope.async vs GlobalScope.launch

**URL:** <https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372>\
**Category:** Libraries\
**Created:** [March 30, 2021, 5:24pm UTC](https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372 "2021-03-30T17:24:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amtrax325](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@amtrax325](https://discuss.kotlinlang.org/u/amtrax325)\
**Post date:** [March 30, 2021, 5:24pm UTC](https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372/1 "2021-03-30T17:24:29Z")

</div>

Hi,  
I’m learning Kotlin Coroutines. Code below shows time measure between `GlobalScope.async` vs `GlobalScope.launch`. The problem is that result is same despite that first part is executed asynchronously.

```
 fun main(args: Array<String>) {
     runBlocking {
         println("aSync GlobalScope")
        var time = measureTimeMillis {
            val a1 = GlobalScope.async {
                delayOnSecond(1000)
                delayOnSecond(500)
            }
            val a2 = GlobalScope.async {
                delay(1000)
                delay(500)
            }
            a1.await()
            a2.await()
        }
        println("Total time: $time")
        println("sequential GlobalScope")

         time = measureTimeMillis {
             val a1 = GlobalScope.launch {
                delay(1000)
                delay(500)
            }
             val a2 = GlobalScope.launch {
                delay(1000)
                delay(500)
            }
            a1.join()
            a2.join()
        }
        println("Total time: $time")

    }

}

```

Shouldn’t be in second example 3000ms rather than 1500?

---

<div class="post-metadata">

**Author:** ![ebrowne72](https://avatars.discourse-cdn.com/v4/letter/e/85f322/32.png) [@ebrowne72](https://discuss.kotlinlang.org/u/ebrowne72)\
**Post date:** [March 30, 2021, 9:24pm UTC](https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372/2 "2021-03-30T21:24:12Z")

</div>

They both execute asynchronously. The difference between `async` and `launch` is that `async` returns a value and `launch` doesn’t.

---

<div class="post-metadata">

**Author:** ![john.pywtorak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/john.pywtorak/32/8977_2.png) [@john.pywtorak](https://discuss.kotlinlang.org/u/john.pywtorak)\
**Post date:** [January 21, 2022, 5:24pm UTC](https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372/3 "2022-01-21T17:24:12Z")

</div>

I thought launch returns the job, which is a lifecycle for the scope?, so you can cancel and other things. So, it has a return, but it is not the results (learning).

---

<div class="post-metadata">

**Author:** ![nickallendev](https://avatars.discourse-cdn.com/v4/letter/n/cdc98d/32.png) [@nickallendev](https://discuss.kotlinlang.org/u/nickallendev)\
**Post date:** [January 21, 2022, 5:44pm UTC](https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372/4 "2022-01-21T17:44:28Z")

</div>

> [@ebrowne72](#):
>
> The difference between `async` and `launch` is that `async` returns a value and `launch` doesn’t.

This is referring to the suspend lambda passed in, not the `launch` or `async` method itself. `launch` returns `Job`. `async` returns `Deferred` (which extends `Job`) which also has methods for getting the suspend lambda’s result.

---

<div class="post-metadata">

**Author:** ![john.pywtorak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/john.pywtorak/32/8977_2.png) [@john.pywtorak](https://discuss.kotlinlang.org/u/john.pywtorak)\
**Post date:** [January 21, 2022, 6:38pm UTC](https://discuss.kotlinlang.org/t/coroutine-globalscope-async-vs-globalscope-launch/21372/5 "2022-01-21T18:38:47Z")

</div>

Thanks @nickallendev that makes sense now; However, unsure how anyone would know that though from just that text without the qualification.
