It's not a secret anymore!
The moose likes Threads and Synchronization and the fly likes Multiprocessing and multithreading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Multiprocessing and multithreading" Watch "Multiprocessing and multithreading" New topic

Multiprocessing and multithreading

Kumar Vinay

Joined: Sep 29, 2000
Posts: 23
What is the difference b/n Multiprocessing and multithreading
David Harrigan
Ranch Hand

Joined: Dec 12, 2000
Posts: 52
A thread is a sequential flow of control through a program. Multi-threaded programming is, thus, a form of parallel programming where several threads of control are executing concurrently in the program. All threads execute in the same memory space, and can therefore work concurrently on shared data.
Multi-threaded programming differs from using multiple processes in that all threads share the same memory space (and a few other system resources, such as file descriptors), instead of running in their own memory space as is the case with processes.

Found on the net from various sources...
Prabhjyot Singh

Joined: Dec 28, 2000
Posts: 22
Hi David,
How can two simultaneous processes share data between them, in a typical desktop computer? TA
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

There's an important distinction to maintain among the terms multi-processing, parallel processing, and concurrent processing.
Parallel processing is true super-computer stuff, where multiple CPUs share the load of a single process by breaking it down and executing its code at the same time.
Multi-processing allows for concurrent, not simultaneous, processing. In this case, different processes can be assigned for execution to different CPUs. This can result in overall reductions in the cost of scheduling processes. Whereas parallel processing starts with each CPU or CPU group having its own system bus to work with, in multi-processing there's a common system bus (i.e., bottleneck). So the idea of MP is you can get much of what parallel processing offers, but for far less cost.
These are hardware-based strategies. Multi-threading, by contrast, is software-based. Using threads, it's possible to utilize CPU resources more efficiently. If one part of a program must wait on the results of a system interrupt, for example, another part of the program, say a calculation, could still run, rather than block on the pending interrupt. Multi-threaded programs therefore take advantage of time the CPU might otherwise simply be idling. Strictly speaking, a well-designed multi-threaded program will use resources more efficiently, the end result being that the overall time required for execution is less.
Michael Ernest, co-author of:
The Complete Java 2 Certification Study Guide
[This message has been edited by Michael Ernest (edited December 29, 2000).]

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
sebu koleth

Joined: Nov 26, 2000
Posts: 4
Could you explain, as much as possible, exactly how much of a resource saving threads can contribute to? It seems to me that even if threads are running in the same memory space, as one thread yields to another, some unique details about that thread will have to be saved. What, usually, are these details? In contrast what additional parameters are there for processes?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Multiprocessing and multithreading
It's not a secret anymore!