[英]can I execute a particular block of code inside a method via thread
can I execute a particular block of code inside a method via thread.我可以通过线程在方法内执行特定的代码块吗? As for example
例如
Class A{
public void execute(){
/* some code where threading is not required*/
/* block of code which need to execute via thread */
}
}
class A {
public void execute() {
/* some code where threading is not required*/
new Thread() {
public void run() {
/* block of code which need to execute via thread */
}
}.start();
}
}
yup all you have to do is implement runnable, then call that meathod inside of run()是的,您所要做的就是实现可运行,然后在 run() 中调用该肉类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.