Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can we make the main method as a separate thread in java?because main method call by main thread when program execute

What I have tried:

this is a theoretical question, please reply
Posted
Updated 23-Jan-18 1:42am

Quote:
can we make the main method as a separate thread in java?because main method call by main thread when program execute

Never do this.
main is a special method and you never call it or thread it.
Only solution: move your code in another method and call this method recursively.
 
Share this answer
 
Comments
Member 13638742 23-Jan-18 6:45am    
if we change main method parameters then it becomes normal method so, can we make it thread?
Patrice T 23-Jan-18 8:24am    
Never do this, 'main' is a special method that launch hidden things.
In theory yes, but in practice no. main is a special method that is always required in a Java application, and must conform to the prototype layout:
Java
public static void main(String argv[])
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900