Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialmohamadreza azadi
5,167 PointsI'm so confused about threads Help
guys how do we know it's Time to using thread I mean how do we understand as well it's time to creating a new thread and handle it.? ||Question2: || in the stormy app we were used runOnUithread what's that? as default, we aren't using UI thread? or all our codes don't affect to UI thread? I'm so confused about that subject please help me Ben Deitch
1 Answer
Ben Deitch
Treehouse TeacherHey Mohamadreza!
If you do a lot of work on the main Thread (which is used by default), then you can cause the UI to stutter. To avoid this, you should do that work in a separate Thread. This is especially true when you're doing something with the internet; you don't want your UI to be frozen while you wait for a response.
runOnUiThread is for when you've done some work on a separate Thread, but then need to update the UI. In Android, you are only allowed to update the UI from the UI thread. So to update the UI from a different Thread, we need to use the runOnUiThread method.
Hope that helps!
mohamadreza azadi
5,167 Pointsmohamadreza azadi
5,167 PointsThanks a lot!, once again Ben Saved my life :D