Kotlin Coroutine Builders: launch, async, and runBlocking along with GlobalScope companion object

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 พ.ย. 2024

ความคิดเห็น • 66

  • @SriyankSiddhartha
    @SriyankSiddhartha 4 ปีที่แล้ว +7

    00:00 Introduction
    01:33 Coroutine Builders
    02:57 Purpose of GlobalScope
    08:02 launch coroutine builder
    15:02 async coroutine builder
    19:56 runBlocking coroutine builder
    25:02 Summary
    26:15 What's Next?

    • @khaledsaif3085
      @khaledsaif3085 3 ปีที่แล้ว

      can we get the pdf of the slides used in your videos ? Those would be very helpful for us

  • @jaserq
    @jaserq 3 ปีที่แล้ว

    i am following you from 7 years .. you have a style of teaching . you are proffesional . thank you

  • @chennamsettysijuchennamset4670
    @chennamsettysijuchennamset4670 2 หลายเดือนก่อน

    Way of explaining is excellent 👌

  • @sagarghare9829
    @sagarghare9829 4 ปีที่แล้ว +14

    There are two ways to start coroutines, and they have different uses:
    launch builder will start a new coroutine that is “fire and forget” - that means it won’t return the result to the caller.
    async builder will start a new coroutine, and it allows you to return a result with a suspend function called await.

  • @yashwant_vadali
    @yashwant_vadali 3 ปีที่แล้ว +2

    Hands down. Amazing explanation. Thank you so so much. Very genuine and easiest explanations of all.

  • @rahulh6711
    @rahulh6711 4 ปีที่แล้ว

    Learnt kotlin from your videos only and now coroutines. Thank you so much

  • @siddharthashankar8396
    @siddharthashankar8396 3 ปีที่แล้ว +1

    I watch ur video and its very helpful for us. Can u add series number also so next video can find and watch easily.
    eg
    Coroutine 1: Kotlin Coroutines: Explore what are coroutines in kotlin. Threads vs. Coroutines.
    Coroutine 2: Kotlin Coroutine Builders: launch, async, and runBlocking along with GlobalScope companion object.
    Hope u wll understand...
    otherwise its difficult to find which is next video...

  • @samuel8mile
    @samuel8mile 4 ปีที่แล้ว +2

    Very good man!! Keep going..don't stop the videos!!

  • @kktechnology2684
    @kktechnology2684 3 ปีที่แล้ว +1

    Good video , sound and representation are very good.

  • @ajeenadev6636
    @ajeenadev6636 3 ปีที่แล้ว

    Thanks, Sriyank your videos and class are very clear and informative

  • @jaloliddinabdullaev2310
    @jaloliddinabdullaev2310 2 ปีที่แล้ว

    Thank you bro for making understandable video, I appreciate your work.

  • @redfox6089
    @redfox6089 3 ปีที่แล้ว +1

    Bravo!!! Excellent teaching skills you have!!!

  • @sunilkumar-zl6eo
    @sunilkumar-zl6eo 3 ปีที่แล้ว

    Great teaching Sir....Respect from heart.....keep Continue...

  • @khairul640
    @khairul640 3 ปีที่แล้ว

    Thanks Sriyank ..your videos are concise and to the point. Please keep sharing knowledge like this..just one thing can you please create a playlist on the Coroutine Videos?

  • @nandhinikajendhiran4634
    @nandhinikajendhiran4634 3 ปีที่แล้ว

    Thank you Android God..clear explanation.. Thanks a lot...

  • @shwetapathak5240
    @shwetapathak5240 4 ปีที่แล้ว +1

    Hey Sriyank..you are awesome.. thank you for being back again..I was wondering why you stopped making videos....

    • @smartherd
      @smartherd  4 ปีที่แล้ว +3

      More to come!

  • @niveditaghosh7899
    @niveditaghosh7899 2 ปีที่แล้ว

    Hi Sriyank,
    I am very thankful to you for making Android simpler. I got deep knowledge in android along with Kotlin. Can you please please make a course over MVVM architecture???

  • @rasoolmohamed4788
    @rasoolmohamed4788 3 ปีที่แล้ว

    in layman's language, nice and simple, and Perfect!

  • @kgkg9829
    @kgkg9829 3 ปีที่แล้ว

    Perfect explanation. Thank you very much.

  • @jeebanbagdi3396
    @jeebanbagdi3396 3 ปีที่แล้ว +1

    #2:24 GlobalScope are Companion Object.
    But GlobalScope are singleton object i think.

  • @AkashJhaDDN
    @AkashJhaDDN 4 ปีที่แล้ว +1

    Thankyou for sharing your knowledge

  • @dibyaranjanmishra4272
    @dibyaranjanmishra4272 3 ปีที่แล้ว

    excellent explanation

  • @kushjaiswal9364
    @kushjaiswal9364 4 ปีที่แล้ว +1

    Sir i don't know kotlin so i am wating for your flutter tutorials....plz sir understand the problem....

  • @parveensharma2270
    @parveensharma2270 2 ปีที่แล้ว

    Sid nice tutorial

  • @amitmondal7427
    @amitmondal7427 4 ปีที่แล้ว +1

    Thanks again.

  • @jayantkumar1954
    @jayantkumar1954 4 ปีที่แล้ว

    It's just awesome.. Thank you sir 👍

  • @yuruar
    @yuruar 3 ปีที่แล้ว

    Amazing video

  • @soumayamondal6915
    @soumayamondal6915 3 ปีที่แล้ว

    Thank you sir

  • @anithamannem9880
    @anithamannem9880 4 ปีที่แล้ว +2

    Please explain about Dispatchers

  • @jagadhisshdeveloper1689
    @jagadhisshdeveloper1689 4 ปีที่แล้ว +1

    Tq very much sir..

  • @vengateshm2122
    @vengateshm2122 4 ปีที่แล้ว

    You are a smart nerd.

  • @atulpradhan6113
    @atulpradhan6113 2 ปีที่แล้ว

    thanks

  • @roopkishore785
    @roopkishore785 3 ปีที่แล้ว +1

    I am not able to use "launch" to create a coroutine, it's showing = Unresolved reference: launch, Please tell what to do?

  • @sohamshinde1258
    @sohamshinde1258 3 ปีที่แล้ว +1

    fine

  • @kushjaiswal9364
    @kushjaiswal9364 4 ปีที่แล้ว +2

    Sir plz provide advance tutorials on flutter....

  • @Rajmanov
    @Rajmanov 4 ปีที่แล้ว +1

    the best!

  • @kalimullakalim5258
    @kalimullakalim5258 2 ปีที่แล้ว

    Thank u

  • @sagaravhad5198
    @sagaravhad5198 4 ปีที่แล้ว

    Thank you

  • @TheMyth2.9
    @TheMyth2.9 2 ปีที่แล้ว

    Very good explanation. But Kotlin is making things confusing. Just putting a string like that without any return statement is very confusing. When I try just launch I get launch reference not found

  • @jagadhisshdeveloper1689
    @jagadhisshdeveloper1689 4 ปีที่แล้ว +1

    Sir please do a video on flow and withContext sir for safe api call in single place sir...or any course u have sir.. on that

  • @rahulhawge2107
    @rahulhawge2107 3 ปีที่แล้ว

    This is gold stuff

  • @jeebanbagdi3396
    @jeebanbagdi3396 3 ปีที่แล้ว

    As per doc and u also saying that async builder is not associated with job object. But with async builder we can return job object and also use job.join() for wait to complete async block.
    How? I am just confusing..

  • @thewalker3491
    @thewalker3491 4 ปีที่แล้ว

    Sir plz make videos on advance flutter

  • @kushjaiswal9364
    @kushjaiswal9364 4 ปีที่แล้ว +1

    Sir is java necessary for Kotlin....plz guide sir....

    • @smartherd
      @smartherd  4 ปีที่แล้ว

      Not necessarily but it helps to understand concepts

  • @safwenchaieb2915
    @safwenchaieb2915 4 ปีที่แล้ว

    amazing explanation

  • @shivamagrawal2284
    @shivamagrawal2284 3 ปีที่แล้ว

    Please create a demo app which includes coroutines

  • @vengateshm2122
    @vengateshm2122 4 ปีที่แล้ว

    Why do we need Dispatchers.IO for network operation if coroutine does not block the current thread?

  • @MusicWorld-fn1zq
    @MusicWorld-fn1zq 3 ปีที่แล้ว

    How do i write launch and async funs in a main thread??

  • @ravidrinek3641
    @ravidrinek3641 3 ปีที่แล้ว

    What is the diff between application lvl thread and the main/UI thread? when using GlobalScope u said it auto uses the application lvl thread and not the main/UI thread (like the 'localScope' launch does when it was called from the main/UI thread) . from my understanding, the application lvl thread IS the main/UI thread

    • @mikec4220
      @mikec4220 3 ปีที่แล้ว +2

      Hi Ravid, I think you are confusing the Scope with the Thread here. The GlobalScope uses the application level Scope which will keep the coroutine alive and working on it's thread (whatever the thread is) as long as the application is running, while creating a Local Scope coroutine it will function as long as the local scope (activity, fragment, etc..) is running.

  • @vengateshm2122
    @vengateshm2122 4 ปีที่แล้ว

    class Calculator {
    fun Double calculateArea(var radius : Double){
    val area = 0.0
    val job = CoroutineScope.launch {
    area = 3.14 * radius * radius
    }
    job.cancel();
    return area
    }
    }
    Assume I am not invoking this in android in activity or fragment or view model or service which has a life cycle.
    I am just invoking in a kotlin code main() function.
    My question is do I need to explicitly cancel the job after area is calculated or whenever the function is executed the coroutine will be cancelled automatically.

    • @mohsanikram3569
      @mohsanikram3569 4 ปีที่แล้ว +1

      I think when normal coroutines done its work, it cancel/finish itself, we don't need to finish or cancel by ourself.

    • @vengateshm2122
      @vengateshm2122 4 ปีที่แล้ว +1

      @@mohsanikram3569 Thank you.

  • @vishalthapa1440
    @vishalthapa1440 3 ปีที่แล้ว

    why runBlocking is used only for testing?we can use globalscope also for test?cant we?

    • @mikec4220
      @mikec4220 3 ปีที่แล้ว

      might be a bit heavy to use GlobalScope

  • @Couple8541
    @Couple8541 3 ปีที่แล้ว

    Any one please .
    Difference b/w delay and job. ?

  • @my_love_sanatan
    @my_love_sanatan 2 ปีที่แล้ว

    watch on 2x