You stop() before you deal with the pong. Using stop() is a bad idea. It's deprecated. Set your threadcontinue var to false to exit the run cleanly.
Anyway - if the first readline isn't ping then you do a second readline to check for pong. That's one readline to many, and the cause of your problem.
Finally
while(threadcontinue==true) {
is redundant, just use
while(threadcontinue) {
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
while(threadcontinue) {
String input = in.readLine().toLowerCase();
if(input.equals("ping")) {
...
}
else if (input.equals("pong")) {
threadcontinue = false;
etc
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
That's good. Time to mark this as "solved".
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
ps: I see you still have the stop() method. It's a really bad idea - you'll get unexplainable thread problems unless you remove it. Also still saying ==true - a personal pet hate of mine.
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Ok i'll change those lol - what do you suggest i do instead of .stop?
See my very first post. (Just set threadcontinue to false)
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073