Reputation: 2045
I am looking to learn more about threading and I wanted to know: what is a multithreaded application?
Upvotes: 18
Views: 70086
Reputation: 1032
Multithreaded applications are the ones which uses concept of Concurrency i.e. they are capable of processing more than one tasks in parallel.
A simple example could be a word-document in which , spell-check, response to keyboard, formatting etc happens at the same time or Concurrently. Internally there are different threads which are doing these task independently.
Source : https://docs.oracle.com/javase/tutorial/essential/concurrency/
Upvotes: 1
Reputation: 28
Multithreading is a mechanism of programing that you can implement in order to gain a remarkable time.
so a Multithreading application is an application that uses more than two threads for two processor or more and it doesn't make sense to have more threads than processor it should be the same.
Upvotes: 1
Reputation: 11
for thread u have to know process which is nothing but instance of program take an example of paint in windows when u run it,it make an one instance or process of paint program. When u open mulitple image on diffenrent window u r making a multiple process of that program. Likewise thread is a unit of process mean u see a paint window but in background there are multiple threads eg.color,brush,pencil,etc. Thread is there to reduce workload of processor
Upvotes: -1
Reputation: 1
what he said
The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources.
Upvotes: 0
Reputation: 36862
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.
Upvotes: 27
Reputation: 230346
It is a program that uses more than one thread. The different threads can access shared memory structures (usually by using appropriate synchronization mechanisms, e.g. locks). An example would be a program that downloads a few files concurrently, each download using a different thread to speed up the download process (there are more sophisticated ways to achieve that, this is just an example).
Multi-threading is often used on CPU-bound tasks, that benefit from using all cores in a modern computer (e.g. trying to break a cypher using multiple processors).
The difference between a thread and a process is that different processes usually cannot directly share memory and data structures, although various mechanisms to share information between processes exist (they are usually more costly than sharing information between threads).
Upvotes: 1
Reputation: 40252
It's an application that can do multiple things at once. 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.
Upvotes: 7
Reputation: 24535
A multi-threaded application takes advantage of running multiple tasks at the same time to speed things up. Multithreading can also take advantage of multiple CPU machines.
Upvotes: 2
Reputation: 60448
It's an application that uses more than one thread internally to accomplish its goal.
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.
Upvotes: 2