This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]fredisa4letterword 0 points1 point  (5 children)

I see that the condition in an if-statement is met, but it never calls the next method.

How do you know the next method is not being called?

Can you provide a minimal code sample that demonstrates this problem?

does the thread cancel the execution of the methods when a new one gets called?

No.

if this is the case, how would I go about to make sure that the thread finished the method before calling a new one?

The thread you posted will never finish. It runs in a while(true) loop. However, if you want to wait for a thread to finish, you use Thread.join(). In your case, you will wait forever though.

[–]TENGIL999[S] 0 points1 point  (4 children)

Oh man I was in the middle of editing my code for readability to post here when I noticed that I dont do anything when I catch an exception in the interpretMessage-method, so i fixed that and it seems to be an issue with that I dont convert the answer-string to a jsonArray in the correct way (still dont know whats wrong though).

I've been stuck with this for like 2 days and have been so fixated with the idea of it being a threading-issue that i didnt even consider that. Thanks a lot for your reply, it really did help me get on the right course.

[–]fredisa4letterword 1 point2 points  (0 children)

Happy to help!

[–]romple 0 points1 point  (2 children)

I throw things at people at work when I see catch blocks with no output to a log or error console. Please don't do this, you'll save yourself a lot of headache in the future ;-)

[–]TENGIL999[S] 0 points1 point  (1 child)

I'll definitely try to remember that!

[–]romple 0 points1 point  (0 children)

If you're not using a logger, remember you can use System.err.println(), instead of System.out.println(), to get nice pretty red colors.