可以从另一个方法挂起java线程(在方法中定义)吗?

时间:2016-01-23 05:56:26

标签: java multithreading

我在方法中定义了一个线程。像这样:

public void startTimer(){
    Thread timer=new Thread(){
        public void run(){
            //do something
        }
    };
    timer.start();
}

我想创建另一种方法:

public void stopTimer(){
    //this method will suspend the thread named timer
}

stopTimer()定义的代码是什么?

0 个答案:

没有答案