File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Diff. betn multithreading and multiprocessing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Diff. betn multithreading and multiprocessing" Watch "Diff. betn multithreading and multiprocessing" New topic

Diff. betn multithreading and multiprocessing

parimal patil

Joined: Jun 25, 2001
Posts: 4
hello! ! !
java guys! ! !
can anybody tell what is the difference between
multithreading and multiprocessing in java.
please i want it in quiet detail.
so i am waiting for possible replys guys.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I would say that multiprocessing is two or more physical, actual processors inside one computer. They are both doing work at the same time, and perhaps on the same 'jobs' or different jobs. A high powered OS would be required to utilize this sort of setup, and it also involves some hardware considerations, because now there are 2 or more processors getting in on the action.

A multithreaded program utilizes the power of one single processor to appear to be doing more than one thing at a time, while in fact, each job is merely time-sharing the processor. The processor only does one thing at at time, but because it only spends 20 milliseconds on each job at any given time, it appears to slow humans that it does multiple things at once. This is also implemented by the OS (and different ones do it differently), but also, programming languages either support or do not support individual 'threads' of operations within a single program!
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Hmmm... I would have thought that multiprocessing involved multiple processes, not necessarily multiple processors. Multiple processes can run on a single processor because the processor does the work of switching from one process to another, very similar to the way the JVM switches between threads in a multi-threaded situation. The differences are:
Multiprocessing Multithreading
OS controls switching JVM controls switching
Different processes can use different languages Threads all use the same language (e.g. Java)*
Each process has its own JVM All threads share a single JVM (running in a single process)

However I may be misinterpreting the terminology here - I trust someone will speak up if this is the case.
* This is excluding the use of the Runtime exec() command, which of course allows you to use all sorts of other non-Java programs and languages. Still, those other languages are being accessed through Java.
[This message has been edited by Jim Yingst (edited June 25, 2001).]

"I'm not back." - Bill Harding, Twister
parimal patil

Joined: Jun 25, 2001
Posts: 4
Thank u very much! ! !
to both of you ! ! !
Mike and Jim ! ! !
This will really help me in understanding the concept.
But still what makes me confused is the concept of Multiprocessing.
Mulrithreading is quite clear.
In multiprocessing , the concept of two processors is quite confusing to me as both of these process are quite complicated to understand.
And I also know this is the question which everyone asks.
But your answers are really great.
so, thanks to both of u again.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Yes, this sort of thing always gets me confused as well. Helped by the fact that different people call the same thing by different names. Multi-processor, multiprocessing, multithreading...

If Unix forks, is that not another 'thread' of excecution, but not the same kind of 'thread' as we think of when we implement the Runnable interface in Java, because perhaps the fork is for a separate program.

A single program written in a language that supports threads is different than an OS that supports multitasking (yet another word), whether it be preemptive or time-shared.

If I have a Java program running that takes a VERY long time to process a certain data chunk, i'll thread that process. So that when I click the "cancel" button on my GUI, it can actually hear it and react by gracefully killing the thread, and I get my program back. But what if I'm also running MS Word and Netscape Navigator... Each of these programs also has it's own thread of execution, which is possible because the OS can do multitasking (or how I maybe should have used the word... multiprocessing).
I tend to think of a single processor doing multiple things as multitasking, a single program that does multiple things as a multithreaded program, and a machine that has two or more processors as multiprocessing/multiprocessor.

But that's only my words.
I agree. Here's the link:
subject: Diff. betn multithreading and multiprocessing
It's not a secret anymore!