我有一个线程,我想进行一些计算,然后将其发送到我程序的主要活动。我怎么能这样做?
线程是
class RemindTask extends TimerTask {
public void run() {
flag = true;
System.out.println(" Hello World!");
for (int e=0; e<2; e++){
fileToReceive = fileparts.peek();
System.out.println("fileToReceive "+fileToReceive);
fileToReceive = fileparts.remove();
}
IntegerResult = 4;
flag=false;
}
我想将 IntegerResult 发送到主要活动。这个计时器是从这里的活动中调用的
Timer timer = new Timer();
timer.schedule(new RemindTask(), 0,30000);
之后我需要将 IntegerResult 带到主要活动的主要活动中,因此主要方法是
int i=0;
//IntegerResult = 4; here i need to take the result of the thread
while (!fileparts.isEmpty() ) { //&& !fileparts1.isEmpty() && (flag == false)
String[] myStringArray = new String[IntegerResult];
for (int e=0; e<IntegerResult; e++){
if (fileToReceive != null && !fileparts.isEmpty() ){
fileToReceive = fileparts.peek();
myStringArray[e] = fileToReceive;
fileToReceive = fileparts.remove();
} else {
myStringArray[e] = " ";
}
System.out.println("myStringArray["+e+"] " + myStringArray[e]);
}