R4R
Right Place For Right Person TM

R4R Java CoreJava FAQs Multithreading

 

Previous

Home

Next

Multithreading

Question: What is Thread and Process?
Ans--
Java support multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Multithreading is a specialized form of  multitasking. There are two types of multitasking:
Thread-based
and Process-based .

Thread-based: A thread is a program which  defines a separate path of execution, the thread is the smallest unit of dispatchable code. This means that a single  program can perform two or more tasks simultaneously.

Process-based : A process is a program that is executing. Thus, process-based multitasking is the feature that allows your computer to run two or more programs concurrently.


Question: What Multithreading?
Ans--
 All modern operating systems support multitasking by virtually . Java also support multithreaded programming. A multithreaded program contains two or more parts that can run concurrently, while
Java programs use the process-based multitasking environments. Multithreading is a specialized form of multitasking.
There are two types of multitasking: Thread-based and Process-based .

Thread-based: A thread is a program which  defines a separate path of execution, the thread is the smallest unit of dispatchable code. This means that a single program can perform two or more tasks
simultaneously. Multitasking threads require less overhead than multitasking processes, Threads are lightweight, they share the same address space and cooperatively share the same heavyweight process while
Interthread communication is inexpensive and unlimited.

Process-based : A process is a program that is executing. Thus, process-based multitasking is the feature that allows your computer to run two or more program concurrently. Processes are heavyweight
tasks that require their own separate address spaces while Intercrosses communication is expensive and limited.

Question: What is Thread Priorities?
 Ans--
Java assigns a priority level to each thread that determines how that thread should be treated with respect to the others. Thread priorities are integers that specify the relative priority of one thread to another.
A thread’s priority is used to decide when to switch from one running thread to the next. This is called a context switch. A higher priority thread is running first than lower priority thread.

The rules which determine the context switch takes place are simple:

1. A thread can voluntarily relinquish control. This is done by explicitly yielding, sleeping, or blocking on pending I/O. In which all other threads are examined, and the highest priority thread that is ready to
run is given to CPU for processing.
2. A thread can be preempted by a higher-priority thread. A lower-priority thread that does not yield the processor is simply preempted no matter what it is doing by a higher-priority thread. Basically, as
soon as a higher-priority thread wants to run, it does. This is called preemptive multitasking.

Previous

Home

Next


Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R