answersLogoWhite

0


Best Answer

"start"

You've created a Thread object and it knows its target. Now it's time to get the whole thread thing running. It's pretty straight forward:

t.start();

Prior to calling start() on a Thread instance, the thread (when we use lowercase t, we're referring to the thread of execution rather than the Thread class) is said to be in the new state as we said. The new state means you have a Thread object but you don't yet have a true thread. So what happens after you call start()?

• A new thread of execution starts (with a new call stack).

• The thread moves from the new state to the runnable state.

• When the thread gets a chance to execute, its target run() method will run.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the name of the method used to schedule a thread for execution?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program in java for creating multiple threads?

class NewThread implements Runnable { String name; Thread t; NewThread(String threadname) { name=threadname; t=new Thread(this,name); System.out.println("New Thread:"+t); t.start(); } public void run() { try { for(int i=5;i>0;i--) { System.out.println(name+ ":"+i); Thread.sleep(1000); } } catch(InterruptedException e) { System.out.println(name+" Interrupted"); } System.out.println(name+" exiting"); } } class MultiThreadDemo { public staticvoid main(String[] args) { new NewThread("One"); new NewThread("Two"); new NewThread("Three"); try { Thread.sleep(10000); } catch(InterruptedException e) { System.out.println("Main Thread Interrupted"); } System.out.println("Main Thread Exiting"); } }Output:New Thread :Thread[One,5,main]New Thread : Thread[Two,5,main]One:5Two:5New Thread : Thread[Three,5,main]Three:5One:4Three:4Two:4One:3Three:3Two:3One:2Three:2Two:2One:1Three:1Two:1One exitingThree exitingTwo exitingMain Thread Exiting


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 does PCO mean for a 28 PCO Thread?

In this case PCO stands for Plastic Closure Only. This is a name for a particular thread used for plastic bottles and caps. 28 stands for the 28mm diameter of the thread.


What is the use of throws io exception in java?

an IOException is any unexpected problem the compiler encounters while attempting to run a program. Possible problems the compiler may encounter are attempting to read from a file that does not exist, write to a file which has an invalid name (a slash or a question mark in the title should do it), or attempting to read the next token in a file when there are no more tokens.


What is static void Main?

The String array args refers to the arguments that the program may require before starting. In many cases you may want the program to take some values as input for processing. this string array is for that purpose.

Related questions

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?


Why is Mary you known as bloody Mary?

Mary I was a staunch Catholic and had a reputation for executing Protestants. Although her preferred method of execution was burning, so technically the name is inaccurate.


What is the name of a spun thread used for knitting and weaving?

yenall thread


Name the three fates?

Clotho, who spins the thread of life Lachesis who measures out the thread with her rodAtropos who cuts the thread


What is a genetic name?

thread


What is the Greek name for Ariadne's thread?

The Greek word for Ariadne's thread is clew.


What is the name of Ariadne's ball of thread?

clew


How do you make a Roblox forum?

You click 'New Thread' Type the name what you want then press creat thread


How do you make a forum on roblox?

You click 'New Thread' Type the name what you want then press creat thread


Why main is static?

The main method is static because the JVM would be invoking this method as the starting point of execution. If this is like other normal methods, the JVM would have to instantiate an object of the class before it can call it. This is not possible because this is the starting point. If the main method is static the JVM can directly call this by specifying the class name.


How can you write a thread programming in net?

This should get you started: using System; using System.Threading; namespace Flurp { public class ThreadTest { private static readonly Random _Random = new Random(); private static void RunThread() { for ( int i = 0; i < 20; i++ ) { string name = Thread.CurrentThread.Name; Console.WriteLine( "{0}: {1}", name, i ); Thread.Sleep(_Random.Next(1000)); } } public static void Main() { Thread thread1 = new Thread( RunThread ); Thread thread2 = new Thread( RunThread ); thread1.Name = "Thread 1"; thread2.Name = "Thread 2"; thread1.Start(); thread2.Start(); } } }


What is a thread path on a sewing machine?

Thread is the name for the string used in sewing. It is usually very thin, so that it is easily put through the eye of a needle and pulled through fabric. It is sold in many colors, and in many different weights.