Wie man diesen Algorithmus besser macht und arbeitet, wo ich immer bis zu reallyFail();
endende bin. Und ich kann es nicht für unbegrenzte Zeit in die Schleife lassen, nur für höchstens 5 Minuten.Java - Wie man diese Algorithmuskorrektur macht, wo ich nicht weiß, wenn value0 und value1 nicht leer und null ist
// This is a heavy rendering encryption which takes sometimes 1 minute
// or sometimes
// it takes less then 1 seconds, very random to estimate to a fix time or delay
prepareEncoding(letter);
// Now once that is done i have two values which if null or empty
// Goal can not be accomplished
if (main.myencryption0 != null && main.myencryption1 != null) {
// Once those value are available
// Proceed to he Goal
prepareToGoal(letter);
} else {
// Value is empty or null we do not know the status
// We try for 3 times the same thing
// (i think this is wrong, but could not find alternative best way)
for (int i = 0; main.myencryption0 == null && main.myencryption1 == null && i <= 3; ++i) {
prepareEncoding(letter);
}
// Wait still for few seconds to make 100% sure
// We can not wait more then 5 minute, because its too long.
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
// Finally again check same thing do or die
if (main.myencryption0 != null && main.myencryption1 != null) {
prepareToGoal(letter);
} else {
reallyFail(); // OK - give up, drop the ball
}
}
was nicht funktioniert? – Woot4Moo
Nicht wirklich sicher, was hier vor sich geht. Wenn du auf das Ende eines Threads wartest, warum warte nicht einfach darauf, dass der Thread beendet wird, anstatt mal zu raten? –
Ich denke, es passt besser für [codereview.SE] (http://codereview.stackexchange.com/) – amit