在静态块中启动线程

时间:2016-02-17 12:16:34

标签: java multithreading static

我想知道以下代码是否正常:

public class MyClass {
...
  static {
    new MyClass().start();
  }

  private void start() {
  //running the thread
  }
}

我必须补充一点,我无法访问类似main方法的内容,因为这部分代码是从外部调用的。

是否存在更复杂的启动此线程的方法?

0 个答案:

没有答案