我正在尝试使用线程等待和通知功能,但是注意到通知功能没有再次调用我的方法。共享我的代码。请让我知道我在做什么错。
sed -e '/mock/R/dev/stdin' -i test{1..500}.txt <mock.txt
sed -e '/mock/{N;s/^\(.*\)mock\(.*\)\n\(.*\)$/\1\3\2/}' -i test{1..500}.txt
public class MainActivity extends AppCompatActivity {
Thread t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t = new Thread(new Runnable() {
@Override
public void run() {
List<Parent> threadList = new ArrayList<>();
threadList.add(new Task1(MainActivity.this));
threadList.add(new Task2(MainActivity.this));
for (Parent task : threadList) {
try {
task.execute();
t.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
t.start();
}
public void getResult(int i) {
Log.i("@@@","Notified"+i);
t.notify();
}
}
任务1之后没有执行任务2