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()
精彩评论