Open GoogleCodeExporter opened 8 years ago
waitForFinish is not in v3.3, it has been removed since the beta version of 3.0
since it promotes the poor practice of locking the thread.
If you must block the thread, you can implement this functionality yourself.
Look at this post:https://code.google.com/p/roottools/issues/detail?id=50&can=1
Original comment by Stericso...@gmail.com
on 7 Oct 2013 at 5:46
Furthermore, you can add a function like this:
private void commandWait(Command cmd) throws Exception {
while (!cmd.isFinished()) {
synchronized (cmd) {
try {
if (!cmd.isFinished()) {
cmd.wait(2000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
Original comment by Stericso...@gmail.com
on 7 Oct 2013 at 5:50
In case I want the source code to preserve it as is, I guess should be
downloading an older version of RootTools. Could you please point me to the
newest version which has waitForFinish?
Original comment by coldpizz...@gmail.com
on 7 Oct 2013 at 5:50
The version 2.6 still has waitForFinish
https://code.google.com/p/roottools/downloads/detail?name=RootTools2.6.jar&can=4
&q=#makechanges
Original comment by Stericso...@gmail.com
on 7 Oct 2013 at 5:54
Thank you so much. It worked flawlessly.
Original comment by coldpizz...@gmail.com
on 7 Oct 2013 at 7:28
I've extended Stephen's solution a bit, added aging:
private void commandWait(Command cmd) throws Exception {
int waitTill = 50;
int waitTillMultiplier = 2;
int waitTillLimit = 3200; //7 tries, 6350 msec
while (!cmd.isFinished() && waitTill<=waitTillLimit) {
synchronized (cmd) {
try {
if (!cmd.isFinished()) {
cmd.wait(waitTill);
waitTill *= waitTillMultiplier;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (!cmd.isFinished()){
Log.e(LOG_TAG, "Could not finish root command in " + (waitTill/waitTillMultiplier));
}
}
Original comment by materem...@gmail.com
on 4 Nov 2013 at 2:47
What I generally do, although I did not show it in my example is to divide the
command timeout into fours and then make the command timeout the max.
Original comment by Stericso...@gmail.com
on 4 Nov 2013 at 2:50
It would be good i thing to let a method or an explanation of how to do it on
the wiki. :)
Original comment by burn2....@gmail.com
on 8 Nov 2013 at 9:47
Original issue reported on code.google.com by
coldpizz...@gmail.com
on 7 Oct 2013 at 4:58