如果是,那么我们可以将main方法作为java中的线程吗? [英] Can we make main method a thread in java if yes then how?
本文介绍了如果是,那么我们可以将main方法作为java中的线程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以将main方法作为java中的单独线程吗?因为主程序执行时主线程调用
我尝试过:
这是一个理论问题,请回复
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
推荐答案
引用:
我们可以将main方法作为java中的单独线程吗?因为主程序执行时主线程调用
can we make the main method as a separate thread in java?because main method call by main thread when program execute
永远不要这样做。
main
是一种特殊的方法,你永远不会打电话或打线。
Only解决方案:在另一个方法中移动代码并递归调用此方法。
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.
理论上是,但实际上没有。main
是Java应用程序中始终需要的特殊方法,必须符合原型布局:
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:
public static void main(String argv[])
这篇关于如果是,那么我们可以将main方法作为java中的线程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文