answersLogoWhite

0


Best Answer

Start with only a single LWP and let it select a runnable thread. When a
runnable thread has been found, the LWP creates another LWP to look for a
next thread to execute. If no runnable thread is found, the LWP destroys itself.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Describe a simple scheme in which there are as many lightweight processes as there are runnable threads?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What java interface must be implemented by all threads?

Runnable interface


Write an algorithm for Round Robin CPU scheduling using?

On each system clock tick, at interval set by design...If no other runnable threads, return from clock interrupt.Save the currently running thread's context.Restore the next runnable thread's context.Return from clock tick interrupt.Note: Most modern schedulers combine round-robin with priority. In the priority scheme, any runnable thread with a higher priority than the interrupted thread takes precedence. If there are none, then round-robin applies at the current priority. If there are no runnable threads at the current priority, lower priorities are considered until we reach the idle priority thread, which, by the way, is always runnable.Also, there is usually an algorithm that adjusts thread priority dynamically. As the thread runs, if it stays runnable its priority slowly drops from its initial base priority. If it is constantly blocking and then then becoming runnable, its priority increases, often faster than it decreases. This makes interactive threads appear to be very responsive, while CPU intensive threads slowly defer to interactive threads. This is usually a good compromise between responsiveness and throughput.


What is the difference between processes and threads?

The memory space, where a given application is executed is called - process. A Process is the memory set aside for an application to be executed in. Within this process the thing, which is really executed is the thread. The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application. Threads share the address space of the process that created it; processes have their own address. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes. Threads have almost no overhead; processes have considerable overhead. New threads are easily created; new processes require duplication of the parent process. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. A great answer to the question can also be found here: (link moved to link section)


How threads are synchronized in a java?

By using an Runnable and Thread object. EX: Runnable r = new Runnable() { Thread t = new Thread() { @Override public void run() { //place code for new thread here } }; @Override public void run() { t.start(); } }; r.run();


Why do you need runnable interface?

A Runnable Interface is one that is used to create a Java Thread... A Thread can be created in two ways and using the Runnable Interface is one of them. Example: public class Test implements Runnable { public void run(){ .... } } The Runnable interface would have an abstract instance of the method run() which needs to be implemented in the class which wants to create a Thread.

Related questions

What java interface must be implemented by all threads?

Runnable interface


Write an algorithm for Round Robin CPU scheduling using?

On each system clock tick, at interval set by design...If no other runnable threads, return from clock interrupt.Save the currently running thread's context.Restore the next runnable thread's context.Return from clock tick interrupt.Note: Most modern schedulers combine round-robin with priority. In the priority scheme, any runnable thread with a higher priority than the interrupted thread takes precedence. If there are none, then round-robin applies at the current priority. If there are no runnable threads at the current priority, lower priorities are considered until we reach the idle priority thread, which, by the way, is always runnable.Also, there is usually an algorithm that adjusts thread priority dynamically. As the thread runs, if it stays runnable its priority slowly drops from its initial base priority. If it is constantly blocking and then then becoming runnable, its priority increases, often faster than it decreases. This makes interactive threads appear to be very responsive, while CPU intensive threads slowly defer to interactive threads. This is usually a good compromise between responsiveness and throughput.


How can you create threads in Java?

You can create threads by two ways in Java:By extending the Thread class orBy implementing the Runnable interface.Ex:class MyFirstThread extends Thread {public void run() {System.out.println("Important job running in MyFirstThread");}}orclass MyFirstRunnableClass implements Runnable {public void run() {System.out.println("Imp job running in MyFirstRunnableClass");}}


What is the difference between processes and threads?

The memory space, where a given application is executed is called - process. A Process is the memory set aside for an application to be executed in. Within this process the thing, which is really executed is the thread. The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application. Threads share the address space of the process that created it; processes have their own address. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes. Threads have almost no overhead; processes have considerable overhead. New threads are easily created; new processes require duplication of the parent process. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. A great answer to the question can also be found here: (link moved to link section)


How threads are synchronized in a java?

By using an Runnable and Thread object. EX: Runnable r = new Runnable() { Thread t = new Thread() { @Override public void run() { //place code for new thread here } }; @Override public void run() { t.start(); } }; r.run();


Why do you need runnable interface?

A Runnable Interface is one that is used to create a Java Thread... A Thread can be created in two ways and using the Runnable Interface is one of them. Example: public class Test implements Runnable { public void run(){ .... } } The Runnable interface would have an abstract instance of the method run() which needs to be implemented in the class which wants to create a Thread.


What is processes threads?

different paths of control in a program that a computer might run at the same time if it has parallel processing support for multithread execution. threads and processes are two ways of supporting multitasking on a uniprocessor or multiprocessing on a multiprocessor. threads are lighter weight: take less OS resources to implement but only support limited protection and security. processes take more OS resources but can support full protection and security. Many operating systems support both processes and threads, allowing each process to have many threads.


Why java called as multithreaded programming?

Java is called multithreaded because it allows the programmer to define multiple threads of execution manually. The main program would continue to execute as one thread and we can speed up the processing by declaring individual threads. Threads in Java can be created in two ways: 1. By extending the Thread class & 2. By implementing the Runnable interface


How process and threads relate to CPU architecture?

A process is a program in execution,it needs resources like CPU time,memory,files and i\o devices to accomplish its task. Threads are lightweight process


Compare and contrast between threads and classes in java language?

A thread is like any other class, except that there is the capacity to run multiple threads - multiple processes - simultaneously.


What is relationship between process and thread?

Process --1------------m-- Threads 1 process to many threads Bring up your Task Manager (if you are using a windows), Performance tap, you can see the number of process and the number of threads, usually the number of threads is a lot higher than the number of processes.


If process stop its execution will thread also stop or it will continue to run?

Processes do not execute, it is the threads within a process that actually execute. All processes have at least one thread of execution, the main thread. If the main thread falls from scope, the process ends, taking all threads with it. This can lead to undefined behaviour if the threads are not terminated gracefully from within the main thread before it falls from scope.