Java run static method in new thread

I just started learning Java, and I encountered a slight obstacle involving threads I have a static method. I want to run it in my own thread. Is this possible? In Python, I know it looks like this:

Solution

Let the run method of thread call the static method:

new Thread(new Runnable() {
    public void run() {
        Call.yourStaticMethod();
    }
}).start();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>