answersLogoWhite

0

No. Each thread can have only one run method. You can overload the run method because it is just another java method but only the default run method with void return type will get called when you start the thread

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

Can you declare more than one single main method in java program why?

It doesn't really make sense. The JVM needs to know where to start running the program; that's what the "main" method is for. A class - one that can be run directly - needs to have a single entry point, to avoid ambiguity. This main method can then call any number of other methods. I assume you can call a second method "main", but using a different signature. However, to avoid confusion, I would recommend you don't do this.


What makes a java method code thread-safe?

The cleanest way to make a method thread-safe is add to the method declaration the synchronized keyword, like this: public class MyClass{ // More code here public synchronized void safeMethod(){ //Do something here, now is safe } } The above code is the same as: public class MyClass{ // More code here public void safeMethod(){synchronized (this){ //Do something here, now is safe } } }


What is the difference between single and double threaded wood screws?

By 'single threaded' you really mean single start thread. So there is just one continuous thread running up the screw. Double start thread means that two threads start from the point and run up the screw entwined with each other. For the same thread spacing the double start will screw into the wood twice as quick but require more torque to drive it. Double or Twin start often used with power screwdrivers.


Define method overloading and write two method headers that together exhibit overloading?

Method overloading is when two or more methods have the same name, but the computer can differentiate between the methods by looking at the parameters. Example: public static void go(int x) public static void go(double x) If you pass an int, the first method would be called. If you pass a double, the second method would be called


What is the distinction between a world-level method and a class-level method?

a class level deals with a single object in a particularly group but the world-level method deals with more than one object in a particular group.

Related Questions

What is the difference between single threaded and multi threaded process?

A write-up of the answer to this question can be found here:http://msdn.microsoft.com/en-us/library/ms693344(VS.85).aspx"There are two types of apartments: single-threaded apartments, and multithreaded apartments. * Single-threaded Apartments-Single-threaded apartments consist of exactly one thread, so all COM objects that live in a single-threaded apartment can receive method calls only from the one thread that belongs to that apartment. All method calls to a COM object in a single-threaded apartment are synchronized with the windows message queue for the single-threaded apartment's thread. A process with a single thread of execution is simply a special case of this model.* Multithreaded Apartments-Multithreaded apartments consist of one or more threads, so all COM objects that live in an multithreaded apartment can receive method calls directly from any of the threads that belong to the multithreaded apartment. Threads in a multithreaded apartment use a model called free-threading. Calls to COM objects in a multithreaded apartment are synchronized by the objects themselves."


What is the advantage of a triple thread screw over a single thread?

The advantage of a double or triple thread over a single is that you develop more travel per rotation while maintaining large thread surface area. You will often find double/triple threads in linear actuators and CNC machines because it increases the rate of travel for a given rpm while maintaining thread strength.


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?


What are the importance and uses of single and double thread?

Single thread is used for simple sewing projects where a lighter weight thread is sufficient. Double thread is commonly used for stronger stitching and can provide added durability for seams that need to withstand more stress. Both threads have their own uses based on the type of fabric and project being worked on.


Which massage methods seem more mechanical?

Swedish movements is type of massage method that is more mechanical


Which massage methods seen more reflexive?

The vascular reflexive technique is a reflexive massage method


What is a method of termite treatment that I can do at home?

There are many methods of pest and termite treatments. Some of the more effective methods are sprays, fogs, and pest services.


Can you declare more than one single main method in java program why?

It doesn't really make sense. The JVM needs to know where to start running the program; that's what the "main" method is for. A class - one that can be run directly - needs to have a single entry point, to avoid ambiguity. This main method can then call any number of other methods. I assume you can call a second method "main", but using a different signature. However, to avoid confusion, I would recommend you don't do this.


How do you overload a method?

Just create two or more methods with the same name, but with a different set of parameters.


Which CPUs have extra hardware built in to allow more than one thread to be processed at the same time on a single CPU?

Multicore


What makes a java method code thread-safe?

The cleanest way to make a method thread-safe is add to the method declaration the synchronized keyword, like this: public class MyClass{ // More code here public synchronized void safeMethod(){ //Do something here, now is safe } } The above code is the same as: public class MyClass{ // More code here public void safeMethod(){synchronized (this){ //Do something here, now is safe } } }


What is the difference between single and double threaded wood screws?

By 'single threaded' you really mean single start thread. So there is just one continuous thread running up the screw. Double start thread means that two threads start from the point and run up the screw entwined with each other. For the same thread spacing the double start will screw into the wood twice as quick but require more torque to drive it. Double or Twin start often used with power screwdrivers.