[問題] Thread使用變數的問題
請問各位
我想要在run()裡面 使用到在main裡面已經處理過的int[] A陣列
main裡面有迴圈是處理封包,有些資訊會存在A[] 裡面
由於封包一直進來,我希望用Thread跑回圈 定時檢查!!
請問該怎麼做到呢??
public class Test extends Thread{
public void run(){
while(true){
//do someting about A
}
}
public static void main(String[] args){
int[] A = new int[10];
// ....
// ....
new Test().run();
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.110.61.14
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):