こんにちは私は次のコードを持っています:
public Item get(int id)
{
Item i = null;
for(Worker w : workers)
{
w.get(id, i); // Several threads start reading that item from data sources
}
while(i == null) // Loop until item is found
{
// this.pause(); there should be a pause but it's not a thread, so I can't do it.
}
return i;
}
その空のループがなければ、もっと良い方法があるはずだと思います。
get関数を一時停止し、ワーカーの1人からの通知があった場合にのみ再開することを含む何か。