我正在尝试通过ScheduledExecutorService
. 因此,我创建了一个从网站加载数据的生产者工作线程和过滤此数据的消费者线程。这是演示我的问题的代码片段:
public void RunPeriodicBackgroundTasks() {
private final ScheduledExecutorService backgroundTaskExecutor_ = Executors.newScheduledThreadPool(2);
backgroundTaskExecutor_.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
LinkedHashMap<String, Object> result_ = new LinkedHashMap<String, Object>(lowLevelNetworkOperation_.executeServerCommand(DASHBOARD_INBOX_SENT_COMMAND, params));
}
},1 ,3, SECONDS);
//AND NOW I CREATE ANOTHER THREAD for the second task
backgroundTaskExecutor_.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
//HERE I WANT To USE result_
}
}, 1,3, SECONDS);
}