answersLogoWhite

0

What else can I help you with?

Related Questions

How do you implement runnable interface?

By implementing Runnable in our class and by overriding the run() method of Runnable interface


What cannot be renewable?

Wind and water are not a runnable resource.


Describe a simple scheme in which there are as many lightweight processes as there are runnable threads?

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


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 java interface must be implemented by all threads?

Runnable interface


Describe a simple scheme in which there are as many light weight processes as there are runnable threads?

A simple scheme to achieve one lightweight process (LWP) per runnable thread is to use a user-level threading library that maps each thread to an LWP. In this setup, when a thread is created, a corresponding LWP is also created, allowing the operating system to schedule them independently. The LWP can manage the execution of the thread, enabling multiple threads to run concurrently on available CPU cores. This approach ensures that each runnable thread has a dedicated LWP, facilitating efficient context switching and resource utilization.


Which among is thread class a sleep b isLive c isAlive?

sleep ().. Runnable r1 = new Runnable() { public void run() { try { while (true) { System.out.println("Hello, world!"); Thread.sleep(1000L); }


Multithreading in java?

I am assuming that you want to know how to multithread in Java. 1) Write a class that implements Runnable. Put just the method run() in it. 2) Inside the run() method, put the code that you want your thread to run. 3) Instantiate the class (example: Runnable runnable = new MyRunnable();) 4) Make a new Thread (example: Thread thread = new Thread(runnable, <the name of your thread(optional)>); 5) Start the thread (example: thread.start();) 6) That's it! Your thread is now running. PS. Check the Java API for more information. Did that answer your question?


If Runnable interface is better than Thread class than why you are using Thread class What is the need for Thread class?

Though implementing Runnable interface is better approach than inheriting from Thread class but there are certain methods available in Thread class like join,sleep or yield which does not available in Runnable interface and programmer can not use them unless he has object of Thread class. This is why we should have Thread class Object. Rupesh Raghani


Describe the Life cycle of a thread in java.?

Life cycle of a thread New: when a thread is not yet initialized, it is in New state Runnable or Ready : Once the thread is initialized and its start method is called, then the thread becomes ready for execution, which is otherwise called runnable or ready state Not Runnable : When a thread is asked to sleep for some time or wait for some time by using the sleep or wait method, thread goes to Not Runnable state for the specified time. Dead state: Once the thread is executed,it turns to dead state. Hope this would answer your question. let me know if you are still not clear


What are the two ways of spawning a thread in Java?

You can create a Thread in Java by using two ways. 1. Extending the Thread class public class Test extends Thread { ..... } 2. Implementing the Runnable Interface public class Test implements Runnable { ... }


What command in Linux do you use run an executable file?

if the file is allready runnable you can type in the terminal: ./filename