I have tried just about everything I know to fix this problem but nothing is coming clear to me. Below is the code in a class that will return the thread name. Now if the thread's name matches the one provided to this method, then it will return the index of that ArrayList. Problem is, the bool is true however it never seems to enter the if statement. just moves around it and instead returns ERROR_NOTFOUND symbol. This would imply that the program ignores the contents of the if statement and moves on to the second return, completely bypassing the chance of ever hitting the first return. Thus never reaching 'return i;'....
I have debugged this many times to no avail with little to no answers as to why. Feel free to run the arbitrary code and try for oneself. I have completely stripped the project down to this and still nothing. Yet applying the answer i have below works.
My thinking is it has something to do with the keywords used. Also, in my digging for an answer, I'm yet to come across anything that helps. So let me know if there is an answer somewhere so that I may be able to better my searching skills.
private static int searchThread(ArrayList<Thread> threads, String name) {
int i;
for (i = 0; i < threads.size(); i++) {
Thread thread = threads.get(i);
String temp = thread.getName();
Boolean bool = temp.equals(name);
if (bool) {
return i;
}
}
return ERROR_NOTFOUND;
}
EDIT: to further the details, i have debugged this code. I have also try to clean and rebuild, thinking that was the problem, but neither helped. So it is a problem with my logic or lack of understanding the true impacts of either the keywords used, UI Thread used, or something else unbeknownst to me.. Any ways the section of code runs on the UI Thread which has never been a problem until now? The if statement is NOT ignored with "return i" is replaced with "return 1". It will then return 1 successfully.