[英]can I execute a particular block of code inside a method via thread
我可以通過線程在方法內執行特定的代碼塊嗎? 例如
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();
}
}
是的,您所要做的就是實現可運行,然后在 run() 中調用該肉類
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.