The problem:
I have 2 methods:
proccessRequest();
proccessResponse();
if I run them so then I get an error because the request proccessing take too long and the response part gives an error. But if I add Thread.sleep(300); between them, then it run fine.
proccessRequest();
Thread.sleep(300);
proccessResponse();
What would be a good solution for this? Stopping the app with Thread.sleep isnt a good solution.
Should I use some kind of timer?
Look for locks and conditions. Your response needs to wait for the request to complete. If they are threads, your response needs to Join the request.