Mastering Concurrency in iOS - Part 2 (Dispatch Queues, Quality of Service, Attributes)

Поделиться
HTML-код
  • Опубликовано: 1 авг 2024
  • In this video, I have discussed Dispatch Queues in detail. System provided queues, custom queues, main queue, Quality of Service, why QoS was introduced, attributes like concurrent, initiallyInactive.
    Apart from these, a little advanced concepts like target queue, and auto release frequency have also been discussed.
    00:00 Start
    1:50 Main Queue
    3:32 Global Concurrent Queues
    7:47 Quality of Service
    17:57 QoS in Action (code)
    23:04 Attributes
    24:03 Target Queue
    28:28 Target Queue in Action (code)
    33:36 Auto Release Frequency
    39:44 Custom Queue using Main Thread

Комментарии • 62

  • @venusajja7038
    @venusajja7038 23 дня назад

    Explained very well. Thanks a lot!

  • @sanilabraham9209
    @sanilabraham9209 6 дней назад

    Excellent work done...congratzzzzzzz

  • @swapnilmore3944
    @swapnilmore3944 Год назад +2

    I listen only audio without video, still able to grasp many of the concepts.... Clear explanation throughout.
    I did watch the video again for the code examples though.....its my habit to listen podcasts while driving. 😊

  • @fatimaakram9602
    @fatimaakram9602 Месяц назад

    Love your videos, so helpful!

  • @arthurschilling5651
    @arthurschilling5651 2 года назад +5

    I feel so lucky to have looked for this topic and found this video, especially just less than a week after it was uploaded! very informative and helpful! Can't wait for the interview questions video as I got my interview in about a week! Pressure is on! Thanks so much again! :)

  • @mahendranj7268
    @mahendranj7268 10 месяцев назад +1

    One of the best explanations of Concurrency I have come across. Really a great one. Even someone who has no idea about concurrency can understand the topics. Well done.

  • @chathuraellawala8082
    @chathuraellawala8082 Год назад

    Good explanation as always. heavily depending on your explanations. thanks mate. Cheers!!!

  • @techguy8661
    @techguy8661 2 года назад

    This man is just awesome with great content and thoughts on every topic he covered in his videos collection. 🤞

  • @shashwatsinghchauhan4527
    @shashwatsinghchauhan4527 2 года назад

    This was so well planned and so well explained ☺.

  • @TheMihirpatel23
    @TheMihirpatel23 Год назад

    Im not joking
    The way he explain concept, deep dive in the problem and provide improvement are really interview style. I passed my interview with help of this video. Thank you, keep doing this video !!!

  • @roshanthapa25
    @roshanthapa25 Год назад

    You've given your best explaining these concepts Pallav.
    These things can be very confusing, I've been there.
    This is, by far, one of the best series on any swift topics.
    I can imagine how much hard work has gone into grasping all this and making the series comprehensive enough for all out there.
    Thanks for sharing your years of hard work and knowledge with us and enlighten us.
    Really appreciate.

  • @ShibasisPatnaik
    @ShibasisPatnaik 2 года назад

    I'm an android dev trying to understand iOS concepts so that I can write kmm libraries. This is the clearest explanation of gcd. Thank you

  • @arthurschilling5651
    @arthurschilling5651 2 года назад +8

    Sorry to comment again… this video series is absolutely blowing my mind. Such interesting content. The fact that the system decides to delegate tasks on the main thread in order not to freeze the rest of tasks when running synchronously is another example of how meticulous and detailed Apple designs it’s system. Unexpected outcome, but it makes sense and I love it! Congrats and thanks for these very well explained concepts!

    • @mazedar_tv
      @mazedar_tv 8 месяцев назад

      interesting thing is he is taking extra effort and creating editing video at 1:00 AM to 2:00AM

  • @anushacheedella2291
    @anushacheedella2291 Год назад

    Crystal clear explanation!!! Kudos for the effort you are putting to explain each and every concept from basics to advanced!

  • @sarahstice4095
    @sarahstice4095 Год назад

    The examples you have in these videos are extremely helpful. I really appreciate how you give an example and then give time to pause to think through the order of task completion is wonderful and helps me so much to understand the concepts. I said it on the last video and will say it again, this is the best video I've seen to help understand these tough concepts. You are doing a great job, thank you very much.

  • @user-op1vf3vb4d
    @user-op1vf3vb4d 9 месяцев назад

    Explained very well. Thanks Pallav

  • @pavanmanjani7583
    @pavanmanjani7583 2 года назад

    Great Effort. Keep posting

  • @sachinpatil2444
    @sachinpatil2444 2 года назад

    Hey Pallav, really admire your work, I have 11 years of iOS developer experience but the way you explained really eye opener for me. I am using custom queues from long time but my thinking was little bit wrong. You cleared the concept, eagerly waiting for next videos.

  • @007sauravsinha
    @007sauravsinha 2 года назад

    Great work. Thanks 😊

  • @byaruhaf
    @byaruhaf 2 года назад

    Hi Pallav, this content, is next level keep making more & more

  • @suryabhan1000
    @suryabhan1000 Год назад

    Keep sharing, Thanks Pallav

  • @ashupainuly9746
    @ashupainuly9746 2 года назад

    Thank you sir, It is very helpfull, Amazing skills you have to teach other such heavy topics in a very easy way.

  • @anubhavjain700
    @anubhavjain700 Год назад

    Super hero, Very well explained.Thanks

  • @DhavalHNena
    @DhavalHNena Год назад

    27:50 great learning. Thanks a lot!

  • @buba7456
    @buba7456 Год назад

    Great work

  • @pradeepkumar-tm5et
    @pradeepkumar-tm5et 2 года назад

    Hi Pallav, Hope you are doing great. Outstanding explanation on Multithreading. Please keep posting more videos related it iOS. Please share your code snippets which you are using in real time projects which might help us to reduce development time.

  • @bastawa
    @bastawa Год назад

    Nice one!

  • @sambhajihajare8720
    @sambhajihajare8720 Год назад

    Hey pallav your videos on iOS app development are very good and understandable. please upload maximum videos in one month

  • @LifeTravelExplorer
    @LifeTravelExplorer 8 месяцев назад

    Good serious

  • @handshadowfun5976
    @handshadowfun5976 Год назад +1

    Thanks for the awesome video! I have a question about the target queue. I see the video mentioned if we don't specify a target queue, it's 'default priority global queue' by default. Does it mean by default the target queue is a concurrent queue even if the DispatchQueue is a serial queue? Thanks

  • @ashutossahoo8005
    @ashutossahoo8005 2 года назад +2

    Great work Pallav. I am also an ios dev working in Byju's hope oneday we will meet for a great discussion 😊.

  • @jitzzz8013
    @jitzzz8013 11 месяцев назад

    Thanks for the awesome videos! i am watching this playlist second time so will post some of my doubts in all videos hope u will answer.
    I have a question about the target queue. I see in the video mentioned at 30.50 if we don't specify a target queue, it's 'default priority global concurrent queue' by default. Does it mean by default the target queue is a concurrent queue even if the DispatchQueue is a serial queue? in that case queue name "A" should behave as concurrent queue not serial queue. pls confirm ?

  • @ios_interview
    @ios_interview 3 месяца назад

    To understand how target queues consolidate threads, this is a better example. If you use the example given where there are only two queues a and b, and a targets b, you will still have separate threads.
    let t = DispatchQueue(label: "T")
    // try removing the target parameter to see the difference in thread
    let a = DispatchQueue(label: "A", attributes: .concurrent, target: t)
    let b = DispatchQueue(label: "B", target: t)
    a.async {
    for num in 1...5 {
    print("\(num) \(Thread.current)")
    }
    }
    a.async {
    for num in 6...10 {
    print("\(num) \(Thread.current)")
    }
    }
    b.async {
    for num in 20...24 {
    print("\(num) \(Thread.current)")
    }
    }

  • @roh9934
    @roh9934 Год назад

    Difference between qos userinteractive & main thread and an example where we must use userInteractive & cant use main thread?

  • @PratibhaShetty-gc4ln
    @PratibhaShetty-gc4ln Год назад

    How many global concurrent queues we have? Do we have separate queues for handling each QoS?

  • @vinod121121
    @vinod121121 Год назад

    Hey, Need Link for article link from Aina Jain with Code snippet please.Thank you for great video, got to know new concepts like auto release pool, Target queue now.

  • @ImTheShrey
    @ImTheShrey Год назад +2

    Question: if a custom queue inherits behaviour from the target queue and then if you don't explicitly specify a target then as you mentioned it will use the default global queue as it's target (qos: default) then: at this point custom queue is by default concurrent queue no matter what attribute you specify because in last video you mentioned all global queues are concurrent in nature?
    That means in 31:18, queue A should actually be concurrent queue no?
    Is this some missing explanation to this?
    More specifically "If custom queues always inherit target queues then in case of serial custom queues what queue will be the default target queue? "

    • @jitzzz8013
      @jitzzz8013 Год назад

      same question i m also having if u get answer pls let me know as well

  • @sumitrathore8446
    @sumitrathore8446 4 месяца назад

    Where is document link which you mention in video ?

  • @Vinay-xd7du
    @Vinay-xd7du Год назад

    Kindly share aina jane articles url

  • @ahmedaboelsood7224
    @ahmedaboelsood7224 Год назад

    what is the important of the label ??

  • @mallanfreefall
    @mallanfreefall Год назад

    Link to the articles ?

  • @Chirayu19
    @Chirayu19 Год назад

    0 should always come before 11 since user initiated would be start before background.

  • @gladyshilerio2098
    @gladyshilerio2098 2 года назад

    Can you link the articles you mentioned during auto release frequency example?

  • @wompaper
    @wompaper Год назад +1

    39:06 - why is "task running in other thread" printed before "Last line in playground"?

    • @VinayGupta-vz9od
      @VinayGupta-vz9od 3 месяца назад

      same question, please explain

    • @gmchandarana
      @gmchandarana 2 месяца назад

      Because by the time control reached at the "Last line in playground", the async block submitted to the serialQueue (didn't matter if it was a concurrent queue) started being executed. Remember - all queues are concurrent relative to each other.

  • @KranthiKumar-hw4ij
    @KranthiKumar-hw4ij Год назад +1

    At 6:15 why was second statement executed first rather than the first statement, as both are assigned asynchronousily?

    • @roh9934
      @roh9934 Год назад

      Both are assigned async. but the Queues are different and Threads are different.

    • @jitzzz8013
      @jitzzz8013 Год назад

      same question i m also having if u get answer pls let me know as well

    • @theakshatpatel
      @theakshatpatel 4 месяца назад

      Because main thread is busy by default trying to do UI things. If you print a lot of numbers (say 10000) in a loop in both queues, you will see that main and background queue are intermingling - but background queue will print lot of things first. That is because by default background queue does not have much to do, so it finishes the tasks faster. (This would change if your background queues were doing heavy operations).

    • @ios_interview
      @ios_interview 3 месяца назад

      @@theakshatpatel I tried the printing of both, they don't intermingle. That being said, the main thread being busy is correct. If you replace the main queue with a created serial queue, the serial queue will run first.

  • @candyman3537
    @candyman3537 Год назад

    Where is a code running when it's not inside main/global or custom queue?

    • @roh9934
      @roh9934 Год назад

      In Background Queue.

    • @MrNinja342
      @MrNinja342 Год назад

      By default it is main queue.

  • @ajaybabusingineedi5797
    @ajaybabusingineedi5797 Год назад

    👌

  • @victorriurean
    @victorriurean 7 месяцев назад

  • @PratibhaShetty-gc4ln
    @PratibhaShetty-gc4ln Год назад

    DispatchQueue.main.async {
    if(Thread.isMainThread)
    {
    print("main thread")
    }
    for i in 0...5
    {
    print("user main \(i)")
    }
    }
    DispatchQueue.global(qos: .background).async
    {
    if(Thread.isMainThread)
    {
    print("user background main thread")
    }
    else
    {
    print("user background not a main thread")
    }
    for i in 0...5
    {
    print("user background \(i)")
    }
    }
    output:
    user background not a main thread
    user background 0
    user background 1
    user background 2
    user background 3
    user background 4
    user background 5
    main thread
    user main 0
    user main 1
    user main 2
    user main 3
    user main 4
    user main 5
    why main thread task is executed at the end?

    • @theakshatpatel
      @theakshatpatel 4 месяца назад

      Because main thread is busy by default trying to do UI things. If you print a lot of numbers (say 10000) in your background queue, then you will see that main queue is not always printing after the background queue. Since the background concurrent queue generally does not have anything to do, it will finish printing first - but not always. You can test this by printing large number of values not just 5 in your loop.