iOS Concurrency and Threading - iOS Interview Question - Swift

  Рет қаралды 107,333

Sean Allen

Sean Allen

Күн бұрын

Пікірлер: 202
@seanallen
@seanallen 4 жыл бұрын
Watch Next - iOS Take Home Project - Job Interview Practice - Free Preview - kzbin.info/www/bejne/g4SslmWva6uYm5o
@seanallen
@seanallen 7 жыл бұрын
Concurrency and Threading can be a tricky topic. Happy to help answer any questions in the comments!
@sashakolsky
@sashakolsky 6 жыл бұрын
Hi Sean, just to clarify, when we say DispatchQueue.main.async that async references the concurrent queue of the main thread, is that it? Does each thread has its own set of two queues (serial and concurrent)?
@victoreysner7630
@victoreysner7630 5 жыл бұрын
Excellent! Thanks for your video and work. But i think we need part 2 with this title. It video skip more detail about multithreading. For example what is deadlock, more detail about flexibilities with Operation and OperationQueue. More detail about API GCD. Maybe few word about api Thread and how depend Thread and DispatchQueue.
@wensmusic8636
@wensmusic8636 2 жыл бұрын
Dude you are an amazing teacher. I really enjoy your teach style, you bring real life examples into code and that really helps with bringing things into perspective. Thank you for taking your time out to teach us all of this. I have an interview tomorrow and I feel so much better now that i've seen your series and I know that i'm hitting on the right topics and that I actually understand them. Thank you bro
@seanallen
@seanallen 2 жыл бұрын
Happy to help. Glad you enjoyed the series!
@dre5671
@dre5671 2 жыл бұрын
Good luck! Hope it went well!
@richardgmartinonline
@richardgmartinonline 7 жыл бұрын
Hi Sean: Job well done. You obviously put quite a bit of time into this video. The explanation is very clear and understandable.
@seanallen
@seanallen 7 жыл бұрын
Thanks Richard, yeah... this was one tough to put together, but I think it turned out ok.
@adeadegoke4925
@adeadegoke4925 7 жыл бұрын
I am upset that 2 people have disliked this tutorial. I can not understand why. Anyway another great tutorial Sean. Keep it up
@seanallen
@seanallen 7 жыл бұрын
Haha, can't please them all, I guess... Thanks for the kind words, Ade!
@DonJon200
@DonJon200 7 жыл бұрын
It has something to do with the Star Wars I guess
@RyuuzakiJulio
@RyuuzakiJulio 6 жыл бұрын
Maybe they wanted an actual working sample code and not the same animations running 20 times and someone typing something and not just talking to the camera?
@seanallen
@seanallen 6 жыл бұрын
??? I don’t even know which video of mine this is referring to. The creator app doesn’t show me. I just know it’s an older video.
@seanallen
@seanallen 6 жыл бұрын
Thanks for the link. Julio misinterpreted the point of the video. This is part of my interview question playlist on how to answer questions you’ll be asked. When on phone screens for interviews they won’t ask you to code this kind of stuff. They’ll want you to explain concurrency and threading at a high level. This video isn’t meant to be a full-blown, in-depth coding tutorial. It’s meant to help newer developers understand the topic at a high level so they can explain it.
@hariharanjagan404
@hariharanjagan404 5 жыл бұрын
i have 8 years of experience in iOS and you videos are simple & great examples
@pawelpow
@pawelpow 3 жыл бұрын
The car highway analogy is the best one I’ve heard so far. You are awesome! You always provide the best explanations
@wanted47
@wanted47 5 жыл бұрын
I’m listening to this while I’m on my way to a technical interview after learning iOS Development for almost a year with zero coding background. Great stuff Sean!
@seanallen
@seanallen 5 жыл бұрын
Good luck on the interview!
@wanted47
@wanted47 5 жыл бұрын
@@seanallenThank you very much Sean. I got the job!!! Looking forward to sharing my story on how I became an iOS dev within a year :D
@seanallen
@seanallen 5 жыл бұрын
That's awesome! Congrats!
@dodilodi1278
@dodilodi1278 2 жыл бұрын
@@wanted47 where is your story :D
@messilicious4045
@messilicious4045 Жыл бұрын
He got busy developing stuff..#nostory
@bibinjaimon
@bibinjaimon 3 жыл бұрын
I've seen this video 3 years ago. Now again came here to recollect things. Thanks for making this video🙂
@atom2ueki
@atom2ueki 7 жыл бұрын
A lot of developers don't have a strong basic knowledge now days and this kind of videos really helps, appreciate it, like your videos, thanks man and keep going!
@seanallen
@seanallen 7 жыл бұрын
Thanks for the kind words, Tony!
@beastgenv
@beastgenv 7 жыл бұрын
That was pretty solid explanation once again, I have been learning iOS Development for the past 6 months now and watched almost all of you videos, great work. Every time I learn at least a thing I did not know before. Thank you.
@seanallen
@seanallen 7 жыл бұрын
Glad you learned something, Alisher! Thanks for watching.
@ambujpunn
@ambujpunn 6 жыл бұрын
Great video Sean. I had a question: You mentioned that you don't manually put anything on the background queue as much...Why is that? I would say it is common practice to manually put API data fetching logic in the background queue. And the only reason one should have to call reloadData for the table view on the main queue is when something has already been put in the background queue (like a manual trigger to fetch data through some API)
@RevanthKausikan
@RevanthKausikan 5 жыл бұрын
Sean, your thoughts on this pease?
@mrmillmill
@mrmillmill 3 жыл бұрын
Great videos! I enjoy your paid courses as well! Very thorough and well executed Sean. Question: what are a list of tasks that happen on background threads vs a list of tasks that happen on main thread? My understanding is closures occur on a background thread and updating UI happen on main thread. Any other logic, tasks, methods etc that directly link to background thread or main thread? Basically, what are the dead giveaways in code that state,”This is background thread or main thread?” Also, what allows you to see what thread something is occurring on? Is there code that will reveal that? Like code for checking type(of:) for data types tells the data type…is there something similar to understand which thread is used for code?
@raousama4276
@raousama4276 5 жыл бұрын
you explained all this in a very simple manner...good job done
@seanallen
@seanallen 5 жыл бұрын
Thanks! Glad you liked it.
@andreadavid5113
@andreadavid5113 4 жыл бұрын
Hey Sean, such an excellent explanation for me as a beginner developer. I wasn't expect that you use a lot of some kind of real-life example like the highway and the queue but you did, so that's nice and very much easy to understand compared to coding. Thank you very much and keep up the good works!
@seanallen
@seanallen 4 жыл бұрын
Thanks for the kind words. Happy hear you enjoyed the explanation 😀
@karooki7219
@karooki7219 6 жыл бұрын
Hey Sean! Absolutely love your videos! Currently just went through a phone screen and 80% of the questions came from your videos so I'm really thankful! Just wondering, what you use to make your animations?
@seanallen
@seanallen 6 жыл бұрын
That's awesome to hear, Karo! Glad I could help in some way. Best of luck on the interview process! For the video animations I just used Key-Frame animations in Final Cut Pro.
@vandanpatel3395
@vandanpatel3395 7 жыл бұрын
Great explanation, Sean. You are right that this is a tricky topic, but whatever you have mentioned in the video, it's more than enough for an iOS Developer to work on Apps.
@seanallen
@seanallen 7 жыл бұрын
Thanks for the kind words, Vandan. It was hard to figure out how to present this topic in the best way. Hope everyone likes it!
@MarcosFelipejchrist
@MarcosFelipejchrist 6 жыл бұрын
Thanks for video . Its the best video about GCD I've ever seen. The video is excellent , audio is great and you can show with animations and codes. You're doing the fantastic work. Congratulations for your work
@seanallen
@seanallen 6 жыл бұрын
Thanks Marcos! This is one of my favorite videos that I've made. Glad you liked it!
@michaelstram
@michaelstram 7 жыл бұрын
DispatchQueue and OperationQueue are so important to learn and understand as an iOS / macOS dev!
@seanallen
@seanallen 7 жыл бұрын
Agreed!
@michaelstram
@michaelstram 7 жыл бұрын
Udacity and the big nerd ranch book on iOS programming have great lessons GCD and when to use operation queue vs. dispatch queue. FLOW is key.
@sashakolsky
@sashakolsky 6 жыл бұрын
Hi Michael, I have the book, but didn't find anything on GDC there at all. Can you reference the pages or section? There are a couple of pages about OperationQueue, but nothing on dispatch that I could find.
@rungxanh2901
@rungxanh2901 3 жыл бұрын
Such an intuitive approach to learn about concurrency and thread. Thank you Sean 🙌🏻
@weepingwillow2056
@weepingwillow2056 3 жыл бұрын
In most cases you embed the switching to the main thread inside the background queue so you call and out layer asych and inside of it a switch to main queue asynch to update UI.
@shadow16g
@shadow16g 5 жыл бұрын
Hi Sean, Thanks again for this tutorials, they are very helpful. I will have an interview soon and I am concerned they may ask whats the difference between Dispatch Queue and NSOperations. Can you share some light :D
@thatmark88
@thatmark88 7 жыл бұрын
Great explain, especially the high way example, but what's the different between queues and thread? Seems they are doing the same purpose of concurrent queue and mutiple-thread...
@mrmillmill
@mrmillmill 2 жыл бұрын
What are a few examples of when you would use the serial queue? Would it be when you’re reloading a table view on the main thread? What are some other examples? Also what are a few examples of tasks to execute on a concurrent queue?
@lennyports
@lennyports 3 жыл бұрын
Hi Sean! Which tasks get executed on the background thread and which tasks on the main thread? You mention UI related tasks should get executed on the main thread, but I am struggling to understand which tasks automatically are executed in the background. Thanks for all of your help! I am huge fan on your videos.
@seanallen
@seanallen 3 жыл бұрын
Hey Lenny, the classic example of the background thread tasks are network calls. Because downloading data from a server takes time (who knows how good the internet connection is), that goes on the background thread as to not disrupt the app running on the main thread.
@soulx520
@soulx520 7 жыл бұрын
Hey Sean, great explanation and for so many of your videos, your analogies are what helps people like me understand these concepts so here, your traffic example or your other video explaining class vs struct with sharing google docs vs sending an email. My question is when do you use .async and .sync? Difference? I can google but your explanations are really helpful. Thanks in advance.
@seanallen
@seanallen 7 жыл бұрын
Synchronous and Asynchronous are basically the same as serial and concurrent, respectively in the video. Something done synchronously is like serial. One thing at a time, and the next task doesn't start until the one before it finishes. Whereas Asynchronously is like concurrent, multiple actions happening at the same time.
@ahujapravir
@ahujapravir 5 жыл бұрын
​@@seanallen Hey! also does sync vs async refers to the task execution on a thread level compared to serial concurrent which is on dispatch queue level? Like if we have a task/operation being submitted to a concurrent queue synchronously then does that mean that the task will be getting dispatched onto different threads, and those threads will get blocked until that task/operation has finished completely. That is, serial blocks queue from starting new tasks and sync blocks threads to include new tasks' execution in between by context switching? Or does sync also blocks the dispatch queue only from starting new tasks? And, sync/async also operate on dispatch queue level only?
@eray9280
@eray9280 Жыл бұрын
Hi Sean. Keep up the good work!
@seanallen
@seanallen Жыл бұрын
Hey Eray... will do!
@genebogdanovich
@genebogdanovich 7 жыл бұрын
Sean, thank you for making these videos! Keep it up!
@seanallen
@seanallen 7 жыл бұрын
Glad you enjoyed it, Gene!
@chillybean9662
@chillybean9662 7 жыл бұрын
Wow this is awesome Sean. Nice use of animations and your explanation is very clear. Keep up the good work, Nice one here!!
@seanallen
@seanallen 7 жыл бұрын
Thanks Chilly! This was a tough one to put together.
@chillybean9662
@chillybean9662 7 жыл бұрын
I must say you will make a good bootcamp instructor or teacher too lol.
@filipsardjoski
@filipsardjoski 7 жыл бұрын
Excellent work! Animation and visual explanation helps a ton 😊
@seanallen
@seanallen 7 жыл бұрын
Thanks Filip! Glad you like it.
@vaibhavdeshpande8643
@vaibhavdeshpande8643 5 жыл бұрын
Hey Sean, great videos... very helpful.... Need a video of concurrency and multithreading with GCD and OperationQueues comparison, what n how more flexibilities we get with OperationQueues, etc.
@seanallen
@seanallen 5 жыл бұрын
Good suggestion. I'll add it to the list!
@batuhankrbb
@batuhankrbb 3 жыл бұрын
I just want to tell you that you are rock! I really love your courses, videos and contents. Keep going
@marinaaguiar5444
@marinaaguiar5444 2 жыл бұрын
wow Sean!! thanks so much for this video! it really cleared up my mind about this topic =) you've done an amazing job with this well didactic tutorial
@waylans
@waylans 4 жыл бұрын
You don't use the background thread when uploading or downloading data?
@dexteritylord1725
@dexteritylord1725 3 жыл бұрын
Thank you for simplifying this.
@shubhammishra-zz1os
@shubhammishra-zz1os 6 жыл бұрын
You are the Best iOS Developer i have ever seen
@seanallen
@seanallen 6 жыл бұрын
Hehe, I appreciate the kind words, but I still have a lot to learn myself. 😀
@israman30
@israman30 7 жыл бұрын
This is a really good tutorial about concurrency. Thanks Sean.., great job.!!
@seanallen
@seanallen 7 жыл бұрын
Thanks Patrick!
@bharatjuneja79
@bharatjuneja79 6 жыл бұрын
Can we call APIs in Concurrent Queue? If yes, then will it help in case we have multiple APIs on same screen. Thanks!
@seanallen
@seanallen 6 жыл бұрын
Yes, you typically make network calls on a background thread (which is concurrent), then once you've received all your data from those network calls, you update your UI on the Main Thread.
@TheZorick
@TheZorick 5 жыл бұрын
finally i undestand the dispatch queue two days ago, i trying to print the content size of tableview but idk it printed 0.0 and i think maybe the value is printed before the tableview load or get the total of content size. and i got the solution in stackoverflow which is to use main dispatch queue and its worked perfectly. so that the thread of print value has moved to main thread which is using the serial queue :)
@seanallen
@seanallen 5 жыл бұрын
That's a big concept to understand. Glad you got it!
@Dineshk1389
@Dineshk1389 3 жыл бұрын
picture can tell thousands words. that picture of express lane(main thread) can have two cars (tasks) side by side. but main thread is an expressway with just one lane so no two cars (tasks) go side by side.
@candylover2456
@candylover2456 4 жыл бұрын
Love your videos! Thanks so much :D Do you have videos on MVC, MVVM, and other patterns? If not, can you please make a video on those topics?
@dylanl9532
@dylanl9532 4 жыл бұрын
In the example you gave, you should add [weak self] in, because the user may chooser to go to a different page while your json data is being loaded. Once it's loaded, self is already removed from memory therefore will cause an error
@seanallen
@seanallen 4 жыл бұрын
This is correct
@stevengao8345
@stevengao8345 7 жыл бұрын
thanks for your time. i do have a question about uimapview, need it need to put to background thread ? if we put something on background thread, is there anything to do with weak reference ? so it may get dismissed and not occupy so many memory? sorry, i am a newbie, got all these silly question on my mind.
@seanallen
@seanallen 7 жыл бұрын
Hey Steven, this question is a little vague and hard to answer with out seeing your specific code. That being said, if you're handing your memory correctly and don't have retain cycles, what queue/thread it's on shouldn't make a difference.
@charmisutariya7060
@charmisutariya7060 5 жыл бұрын
Thank you Sean, These videos are clear and so very helpful.
@seanallen
@seanallen 5 жыл бұрын
Happy to help, Charmi 😀
@charmisutariya7060
@charmisutariya7060 5 жыл бұрын
@@seanallen Omg, I was just watching your videos right now (almost since morning) and seeing your reply, I'm like 🤩
@amari9773
@amari9773 7 жыл бұрын
What monitor are you using? Love your setup.
@seanallen
@seanallen 7 жыл бұрын
Hey Julio, it's an LG 34 inch curved ultra wide. Can see more about it in my Dev Setup video: kzbin.info/www/bejne/kJq8qZJqmsqCo9U
@amari9773
@amari9773 7 жыл бұрын
Sean Allen Sweet. Thanks!
@abdulazizalharbi6228
@abdulazizalharbi6228 4 жыл бұрын
great explanation, now I know the differences between main and global (represent the threads on the device's processor), and concurrent and serial (represent the queue types in each thread ), hopefully I'm right But what I'm confused about, is when I see serial.async, I know serial queue is meant to be one task at a time, how could it be asynchronized? the same for concurrent.sync, the main purpose of the concurrent is to execute multiple tasks at one time, then why would we make it synchronized? Thank you Sean for your high-quality content best,
@vprabhu2906
@vprabhu2906 4 жыл бұрын
@Sean Allen Hi Sean , I watched ur tutorial s , helps a lot, But have a doubt on one thing # Dispatchqueue.main.async "main" was mentioned it was serial queue ( order execution ) so, what the next .async ( it's unorder execution ) I was confusing ,pls clarify
@luciarigoni8289
@luciarigoni8289 Жыл бұрын
Thank you so much for this video!
@seanallen
@seanallen Жыл бұрын
Glad it was helpful!
@TheCarlosAlfaro
@TheCarlosAlfaro 7 жыл бұрын
Hi Sean, what camera and microphone do you use for your videos?
@seanallen
@seanallen 7 жыл бұрын
I use a Canon EOS M3 and a simple RODE lapel mic.
@TheCarlosAlfaro
@TheCarlosAlfaro 7 жыл бұрын
Cool, it looks really nice! thank you!
@MeditativeMonkHeal
@MeditativeMonkHeal 6 жыл бұрын
What is the difference between gcd and queues??
@Jason021376
@Jason021376 5 жыл бұрын
You stated that you never manually sent tasks to the background, so I am assuming that there are conditions when tasks are automatically sent to a background. What are these conditions?
@jameelshehadeh9011
@jameelshehadeh9011 3 жыл бұрын
very simplified and clear thank you Sean
@seanallen
@seanallen 3 жыл бұрын
Glad it was helpful!
@poonamkanuga6127
@poonamkanuga6127 7 жыл бұрын
please do a video on GCD and Nsoperation queue.
@yesbolkulanbekov2878
@yesbolkulanbekov2878 7 жыл бұрын
Imho, one thing hard to understand for beginners is calling Concurrent Queues “queue”. You can’t relate to it to a real life queue. So, it means I was not cutting in line in cafeteria, I was just in a concurrent queue.
@techluthiers8189
@techluthiers8189 5 жыл бұрын
Sean, this video was 1000x times more powerful than the Stanford video out there in youtube for threads btw that video is more than an hour and it is not even 1%worth vs this. Again Thank you. Now, how do I start debugging something that is stuck somewhere in the mainThread (serial) while just opening a vc that hangs just after viewWillAppear()? Thanks for giving me any clue!
@seanallen
@seanallen 5 жыл бұрын
Glad you liked this video! It's one of my favorites as well. I would need more specifics on your issue to be able to help. It's pretty hard trying to help debug via KZbin comments 😀
@krishnakirana8399
@krishnakirana8399 3 жыл бұрын
In concurrency and asynchronous are the same? if not what is the difference?
@TheBooban
@TheBooban 3 жыл бұрын
Whats the difference between Operation and NSOperation?
@isaacclark9825
@isaacclark9825 7 жыл бұрын
Nice explanation. You convinced me that it was time to subscribe!
@seanallen
@seanallen 7 жыл бұрын
Man... that was a hard-earned subscriber, lol. Thanks Isaac! 😃
@isaacclark9825
@isaacclark9825 7 жыл бұрын
Lol! I am not much of a joiner. You gotta show me something!!
@FRUITPUNCH2609
@FRUITPUNCH2609 7 жыл бұрын
you put in a lot of effort, thanks man!!!
@seanallen
@seanallen 7 жыл бұрын
Glad you enjoyed it!
@mishaespinoza3900
@mishaespinoza3900 7 жыл бұрын
Excellent post production skills
@seanallen
@seanallen 7 жыл бұрын
Thanks Misha!
@cosmicjoshgaming3655
@cosmicjoshgaming3655 5 жыл бұрын
I don't understand code ); Is there anyway you can show me your path so I code just like you ?
@quyetbuihuu1599
@quyetbuihuu1599 6 жыл бұрын
thank you. I learned a lot from this video
@shubhpatni2123
@shubhpatni2123 6 жыл бұрын
Love your videos but please make this one with more code examples thank u
@tusharsingh2439
@tusharsingh2439 6 жыл бұрын
just a small trick that i use (only for small projects, maybe using Firebase, etc. ) I load all the JSON data on the initial VC and make a global variable storing all the JSON values , so whenever you need the values you can simply call the global variable on the main thread. Tough this isn't a good programming technique , it works good enough
@LukeSamkharadze
@LukeSamkharadze 2 жыл бұрын
You didn't explain quite clearly, If we have 1 functions for sending tasks to main thread and 1 for background thread, then in which thread we are on?
@benbejster7326
@benbejster7326 6 жыл бұрын
What would happen differently if the tableView was reloaded on the background thread?
@seanallen
@seanallen 6 жыл бұрын
It would take a lot longer to populate and would give your app the appearance of being really slow to load the images.
@RostyslavKobizsky
@RostyslavKobizsky 3 жыл бұрын
How about semaphores and berries?
@wilsonbalderrama
@wilsonbalderrama 7 жыл бұрын
wow impressive explanation Sean, good job!
@seanallen
@seanallen 7 жыл бұрын
Thanks Wilson... this one took some time to put together... Glad you enjoyed it!
@monicaluo1122
@monicaluo1122 4 жыл бұрын
It's a great video! Do you have a video about lock & deadlock, race condition(with more details)?
@seanallen
@seanallen 4 жыл бұрын
Glad you liked it! I do not have a video on those topics.
@DewTime
@DewTime 5 жыл бұрын
I’m still confused because there’s a main thread and then there’s a main queue. And the there’s serial queues and concurrent queues. I don’t think you really tied everything together with dispatchqueue.main.async{}. Does the block of code have anything to do with the main thread or the main queue?
@ashrafshakhatreh3609
@ashrafshakhatreh3609 3 жыл бұрын
how to work on a specific thread of the background thread ?
@Emad-mc9uh
@Emad-mc9uh 5 жыл бұрын
thanks mate
@seanallen
@seanallen 5 жыл бұрын
Thanks! Glad you liked it!
@reyariass
@reyariass 6 жыл бұрын
If you have to send stuff to the main thread a lot, how is stuff sent to the background thread without sending it manually?
@jamesqiu6715
@jamesqiu6715 7 жыл бұрын
You mixed up concurrency and parallism. And.... Without shared resource to protect, what is the CONDITION your thread race for to occupy it?
@cheesetoochalk
@cheesetoochalk 2 жыл бұрын
Excellent job
@vegitoblue4390
@vegitoblue4390 5 жыл бұрын
Awesome video Sean, thanks a ton.
@seanallen
@seanallen 5 жыл бұрын
Glad you liked it!
@maximkrouk1697
@maximkrouk1697 5 жыл бұрын
Shouldn't You use [weak self] in your self.tableView.reloadData() example?
@hugocoutinho3268
@hugocoutinho3268 6 жыл бұрын
Great explanations. Thank you
@seanallen
@seanallen 6 жыл бұрын
Happy to help.
@cozziee92
@cozziee92 7 жыл бұрын
I experienced a bug recently which sort of made a concurrent queue to stop executing tasks altogether if the number of jobs submitted to it is >100ish. Can you throw some light on what might be causing this?
@seanallen
@seanallen 7 жыл бұрын
To be honest, Jatin, I'm not sure what could be causing that issue. Sorry I couldn't be of more help.
@ales_hanzlik
@ales_hanzlik 7 жыл бұрын
Hello Sean, first of all thanks for great explanation. I've a question. I have whole bunch of data (around 300 images) to download and save to core data but when I save objects to core data on the main thread it takes so long and the UI gets frozen. Does that mean I can save core data inside "DispatchQueue.global(qos: .background).async" ?
@eduardoliveros
@eduardoliveros 7 жыл бұрын
I recommend split the process, for example download 10 object for time, and the others in a global queue
@ko-eb6og
@ko-eb6og 7 жыл бұрын
Can i check somehow on which queue my code is?
@ekchhuon4976
@ekchhuon4976 6 жыл бұрын
Great expalanations
@ebukaegbunam4369
@ebukaegbunam4369 5 жыл бұрын
you are an angel
@seanallen
@seanallen 5 жыл бұрын
Happy to help!
@farmood100
@farmood100 6 жыл бұрын
Great job Allen. .......
@aniketayachit2253
@aniketayachit2253 4 жыл бұрын
I'm wondering why we use DispatchQueue.main.async() not DispatchQueue.main.sync()? I was searching for an answer. but did not get promising answer. Hope you can help me out?
@vprabhu2906
@vprabhu2906 4 жыл бұрын
Even I do have confusion, Anything know about this..?
@heyrahulrs
@heyrahulrs 7 жыл бұрын
Amazing video!!🍻
@seanallen
@seanallen 7 жыл бұрын
Thanks Rahul!
@andressaneumann3454
@andressaneumann3454 4 жыл бұрын
excellent video, thank u so much
@seanallen
@seanallen 4 жыл бұрын
Happy to help, Andressa!
@roycheong8250
@roycheong8250 6 жыл бұрын
Excellent. Subscribed + Liked.
@seanallen
@seanallen 6 жыл бұрын
Thanks for the support, Roy 👍
@saad.shamsi.36
@saad.shamsi.36 6 жыл бұрын
Great job. well done and keep it up.
@seanallen
@seanallen 6 жыл бұрын
Thanks Saad!
@HarshitKumar-br3iz
@HarshitKumar-br3iz 5 жыл бұрын
Nice video
@seanallen
@seanallen 5 жыл бұрын
Thanks 😀
@orlandog.rodriguez8837
@orlandog.rodriguez8837 6 жыл бұрын
So just to confirm, any code executed on DispatchQueue.main.async {...} will be done in order?
@seanallen
@seanallen 6 жыл бұрын
You're making sure that code gets executed on the main thread. Yes, whatever code you have in that block will be executed in order.
@nikinlug
@nikinlug 7 жыл бұрын
If you say that you never use DispatchQueue.global.. but you do use DispathQueue.main, then how do you use it? I mean the whole point of dispatching to the main is switching from another queue but you say you don't use it..
@seanallen
@seanallen 7 жыл бұрын
When using NSURLSession for network calls the downloads automatically happen on a background thread. Which is why I rarely move stuff to a background thread manually (manually is the key word there). The very common flow is to download some data from the internet, and then update your UI on the main thread using DispatchQueue.main.async.
@ruimao6191
@ruimao6191 6 жыл бұрын
A follow up question, if you don't manually specify DispathQueue.main, will the UI continue being updated on the background thread?
@sivakrishna5293
@sivakrishna5293 6 жыл бұрын
It's not safe to update your UI in background thread, cause it is unpredictable when your UI gets loaded and it's not recommended, sometimes your app may crash for doing UI stuff in background thread.
@andredouglas6201
@andredouglas6201 3 жыл бұрын
Thanks man
@seanallen
@seanallen 3 жыл бұрын
Happy to help, Andre.
@tusarjn
@tusarjn 6 жыл бұрын
Man how much experience do you have?
@seanallen
@seanallen 6 жыл бұрын
3+ years
@technoforensics
@technoforensics 7 жыл бұрын
@Sean, Thank you. Appreciate it a lot.
@seanallen
@seanallen 7 жыл бұрын
Glad you enjoyed it Joash!
@paramveersingh3491
@paramveersingh3491 4 жыл бұрын
Is main thread free all the time and everthing else is happening on the background thread
@seanallen
@seanallen 4 жыл бұрын
UI stuff is happening on the main thread
@paramveersingh3491
@paramveersingh3491 4 жыл бұрын
@@seanallen Ok thanks sir for helping
@eduardoliveros
@eduardoliveros 7 жыл бұрын
Great video Bro!
@seanallen
@seanallen 7 жыл бұрын
Thanks Eduardo!
@lostintheheatofitall
@lostintheheatofitall 5 жыл бұрын
But why is it .async if its eventually executed in order?
@triple16
@triple16 5 жыл бұрын
The async call will put some task in a dispatch queue and then return. Now the task will be executed asynchronously, in the order of the queue.
@CaffieneToCode
@CaffieneToCode 5 жыл бұрын
Why is UI updated on the main thread?
@pgrm1188
@pgrm1188 5 жыл бұрын
Let me respond you with an example. Let's say you are downloading a big file. You probably want to show the user a progress bar or something. Also, your download would probably be downloaded on a background thread (if not, you're clearly doing it wrong) and then you'd update the progress bar on the main thread. Apple decided that the main thread is mostly reserved for UI because you don't want to have an *unresponsive app* . So why update the UI on the main thread and not on a background thread? Exactly because of what I just said, and also because *the main thread is the one with the highest priority of them all* .
@diakojafari2107
@diakojafari2107 2 жыл бұрын
very good 👍
When to Semaphore vs Dispatch Group! Careful Multithreaded Shared Resource
11:11
ЛУЧШИЙ ФОКУС + секрет! #shorts
00:12
Роман Magic
Рет қаралды 34 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 47 МЛН
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 35 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 1,9 МЛН
Swift Concurrency Manifesto | Chris Lattner and Lex Fridman
10:59
Threads and Grand Central Dispatch in Swift
22:14
Stewart Lynch
Рет қаралды 22 М.
Swift Closures Explained
14:23
Sean Allen
Рет қаралды 67 М.
06. Concurrency - Денис Малых
1:37:09
Yandex for Developers
Рет қаралды 8 М.
Filter, Map, Reduce - Swift - iOS Interview Questions
11:08
Sean Allen
Рет қаралды 54 М.
3 MISTAKES to avoid when using Async / Await in Swift 😌
4:41
Vincent Pradeilles
Рет қаралды 12 М.
ЛУЧШИЙ ФОКУС + секрет! #shorts
00:12
Роман Magic
Рет қаралды 34 МЛН