Follow Our FB Page << >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

How multi processing is achieved in JAVA?

Answers were Sorted based on User's Feedback

How multi processing is achieved in JAVA?..

Answer / javalearner

An operating system executes multiple processes in a manner similar to that for multi-threading, except that each process stack refers to a different program in memory rather than code within a single program. The Java Virtual Machine (JVM), of course, controls the threading within the Java programs, just as the machine OS controls multiple processes.

In some JVM designs, threads can be assigned to native kernel processes in the OS. Furthermore, for operating systems such as Solaris and Windows NT that can control multiple processors, the threads can actually run on different processors and thus provide true parallel processing performance.

Whether its for multithreading or multiprocessing, the two basic designs for this context switching, i.e. the shifting of threads/processes in and out of a processor, include

preemptive or time-slicing - give each thread a fixed amount of time.

non-preemptive or cooperative - a thread decides itself when to surrender control
Generally, the preemptive approach is the most flexible and robust. A misbehaving thread cannot hog all the resources or hang the processor. Unfortunately, the context switching is not specified for Java and so different JVM implementations do it differently. Thus you should design your multi-threaded code for either possibility if you want it to be suitable for broad distribution. This means adding yield()or sleep() calls to release control at suitable points in the thread code.

Is This Answer Correct ?    3 Yes 1 No

How multi processing is achieved in JAVA?..

Answer / simran

by multi threading

Is This Answer Correct ?    6 Yes 10 No

How multi processing is achieved in JAVA?..

Answer / dipil t t

We can achieve this in java by using Interface conscept.

Is This Answer Correct ?    6 Yes 10 No

How multi processing is achieved in JAVA?..

Answer / sharjith n.

First of all, MultiProcessing is different from
MultiThreading. In MultiThreading the same processor
executes the different threads. However there is no
parallel processing of any thread done because finally, one
processor can handle only one task at a time. You feel the
computer is doing many tasks together because of the very
small amount of time between task switching but the
processor is actually doing only a single task. But how
fast the processor is completing all the queued tasks
depends upon the major factor that is the clock speed and
many others too. But when you employ more than one
processor, as in Servers with Multiple CPUs or in the
latest Core2Duo or Core2Quad machines, MultiProcessing
(technically known as Parallel Computing) comes into
picture, where each thread of the same process is assigned
to different processors (or cores in case of the multi core
architectures) using fork-and-join method. In this case two
threads of the same process is parallely executed by two
processors (in case of 2 processors). In C/C++ Parallel
Processing (MultiProcessing ) can be achieved by using the
OpenMP library which is shipped with the latest Visual
Studio compilers and the other compilers like GNU v4.2 and
above and IBM and Intel compilers. You have to write the
programs using the appropriate #pragma statements to fork
and join for loops and also compile the programs with
special flags. Multiple processor or multicore cpus are
useless unless the software you write utilizes them.
My answer does not tell you how to do the same in Java but
you will definitely understand what to search for i.e.
libraries supporting MultiProcessing in Java.

Is This Answer Correct ?    5 Yes 10 No

How multi processing is achieved in JAVA?..

Answer / rajashree

A thread pool is a collection of threads, which you
keep "alive" and use/reuse to process incoming "tasks".
When a new tasks arrives (a typical example is a request to
an HTTP server) you try to find a thread from the
collection, which is idle, and handle the task to it. If no
such thread exists you either wait for one to become
available or add a new thread to the pool (usually there is
an upper limit, though). After the thread has finished
processing the task, it is not terminated, only marked as
idle and ready to be reused for another task.

The main advantages of using a thread pool as opposed to
creating a new thread to handle each new task are:

1) By reusing threads you save the thread
creation/destruction overhead.

2) You have control over the maximum number of tasks that
are being processed in parallel (= number of threads in the

Is This Answer Correct ?    8 Yes 14 No

Post New Answer

More Core Java Interview Questions

What is the use of jtable?

0 Answers  

When should I use singleton pattern?

0 Answers  

Why is the main method static?

0 Answers  

What is OOP?

2 Answers   BMC, Microsoft,

What are the differences between abstract class and interface?

0 Answers  

what is the difference between preemptive scheduling and time slicing? : Java thread

0 Answers  

Explain with example the concept of constant variable in java.

0 Answers   HCL,

Can we overload the main() method?

0 Answers  

How many bytes are a float?

0 Answers  

Is set sorted in java?

0 Answers  

Is java an ide?

0 Answers  

What is the difference between a local variable and an instance variable?

0 Answers