answersLogoWhite

0

Sure you can. The run method is just another java method that you can modify to be private or protected or have return types as Strings etc.

But, this run method will not be invoked when you start the thread. Only the default public void run() will be invoked when you do a thread.start()

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What is the difference of non void and void function?

If a method call is void, that means it will not return a data value to a program that calls it. Otherwise, the method is expected to return a data value of some sort. For example, if I have a method called print() that is void, and the body of the method has a command to print a word to the screen, the method will run that command and end. However, if I have a method called add(int x, int y) that takes two numbers and adds them together, the program calling this method wants an answer back. So this method is not void.


What is the executable method in java?

In Java, the executable method is the main method, which serves as the entry point for any standalone Java application. It is defined as public static void main(String[] args), where String[] args allows for command-line arguments to be passed to the program. The main method must be declared as public and static, and it returns no value (void). When a Java program is run, the Java Virtual Machine (JVM) looks for this method to start the execution of the program.


Can you declared constructor as private?

If you declare the main method anything other than public, it will not run. If you declare main method as private, you would not be able to execute the class as a standalone java program. Any java class that needs to be executed as a standalone file needs to have a main method that is public, static and returns a void. Otherwise the Java compiler would not recognize the file as an executable standalone java file and would not allow you to run it.


What is the void id for rune private servers?

Runescape private servers are not run by jagex. They are what it says... PRIVATE servers. As in they are ran by private websites, and owned by private users. The void id is unique to each private server, and is only known by the owners of the server, and if they choose to announce it, then the public that plays on these private servers.


Can you use two or more run methods for a single thread in same method?

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


Can the main method declared be final?

Sure, it can be declared final! It doesn't matter if it is declared final, the JVM will still find it and run it, and the compiler doesn't care.


How do you call repaint using thread in java applet?

You call the repaint method the same way you'd call any other method from a thread. final Applet appletToRepaint; new Thread() { public void run() { appletToRepaint.repaint(); } }.start();


What is the difference of interface and class?

A (concrete) class defines all his methods and can have any kind of instance variable and is declared with the 'class' keyword. Unlike an interface that doesn't implements any of his methods and his variables must be static and final. An interface is defined with the 'interface' keyword.//This is a classpublic class MyClass{public String name;private int age;public void myMethod(){//do something}}//This is a interfaceinterface MyInterface {public static final String name;public static final int age;public void myMethod(); // This method is not implemented}An other difference is that a class can be inheritance by other class but a interface must be implemented using the keyword 'implements'.interface Runnable(){void run();}public class MyOtherClass implements Runnable{public void run(){// insert interesting code here}}


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();


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.


Public static void main?

"Public" means that anyone can call the method "static" means that that it will not change "void" means that it will not return any value "main" is the actual name that the compiler looks for to run the program I hope this helps.


What is void main?

The main method is the first method, which the Java Virtual Machine executes. When you execute a class with the Java interpreter, the runtime system starts by calling the class's main() method. Themain() method then calls all the other methods required to run your application. It can be said that the main method is the entry point in the Java program and java program can't run without this method.The signature of main() method looks like this:public static void main(String args[])The method signature for the main() method contains three modifiers:public indicates that the main() method can be called by any object.static indicates that the main() method is a class method.void indicates that the main() method has no return value.