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 trial

iOS

Multithreaded Applications

Can someone please give me an example to a multithreaded application so I will understand a little bit better what that means? Thanks!

2 Answers

Multithreading as a widespread programming and execution model allows multiple threads to exist within the context of a single process. These threads share the process' resources but are able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.

That means that a single process can have many different "functions" executing concurrently, allowing the application to better use the available hardware (multiple cores/processors). Threads can communicate between them (they have shared memory), but its a hard problem to have every thread behave well with others when accesing shared objects/memory.

Threading allows an application to remain responsive, without the use of a catch all application loop, when doing lengthy operations.

For example, a non threaded copy program wouldn't allow you to do anything until the copy completes.

Threading helps with complex, lenghty, independent problems, but brings along a lot more complexity, that makes it hard even for seasoned developers.

There are lots of examples, as most application that need to interact with a user have a UI thread and a set of working threads. This is done to allow the UI to remain responsive while the application is busy doing some task.

For example, if you're tying a document in Word, there's a thread responding to your keyboard, there's a thread that's checking your spelling, there's one that's checking your grammar, there may be another thread saving a backup of your document in case the program crashes.

http://stackoverflow.com/questions/1313062/what-is-a-multithreaded-application

Thanks!