可不可以这样?
声明一个在你的主类中static 变量 如test,值为true;
在主类执行到某一步时新建线程类的实例然后启动线程类,在主类的这一步之后用
while(test)
{
}
线程类检查某一个文件的最后修改时间,一旦发生变化即修改test的值为false即通知主类继续往下执行.
声明一个在你的主类中static 变量 如test,值为true;
在主类执行到某一步时新建线程类的实例然后启动线程类,在主类的这一步之后用
while(test)
{
}
线程类检查某一个文件的最后修改时间,一旦发生变化即修改test的值为false即通知主类继续往下执行.
给两个线程各买手机一个,一定要彩屏,多媒体短信
想让哪个停就给哪个发一PPMM片片去,让其流鼻血,直至血尽线程亡
public class Main{
public static void main(String[]args){
Main test=new Main();
Thread thread=new Thread(new MyThread(test));
thread.start();
}
}
public class MyThread implements Runnable{
private Main mainInstance;
public MyThread(Main mainInstance){
this.mainInstance=mainInstance;
}
public void run(){
.....
mainInstance.callback();
}
}
static int yourFlag = 0;
while(true) { //Main cycle
if(yourFlag==1) {
do your processing
}
else {
do another response
}
sleep(xxxx);
}Other thread:
processing.....
MainProcessor.yourFlag = 1;
processing.....
happyegg:如果do another response不是简单的一段代码呢?而是整个应用程序的其他部分呢?包括很多.java文件.
使用回调已经搞定了,多谢!