How to delay an if-statement check? Java/Eclipse

Soldato
Joined
15 Aug 2010
Posts
8,780
Location
N. Ireland
I am just wondering if there is anyway to delay an if-statement check? The condition for the if-statement requires an input value from another class and every time I run the code, it always checks the condition before I can input the value and save it to the variable.
 
Soldato
OP
Joined
15 Aug 2010
Posts
8,780
Location
N. Ireland
I assume this is for some sort of school/university work?

What makes you think you're multi-threading if you haven't looked at that yet and have no knowledge of it?

Can you post a bit more of your code so we can see what's going on?

Yup, uni assignment, it just came up as one of the suggestions when googling :p

Make the class that provides the input a Callable and use the returned Future in your if statement. The thread will block until the input is made available.

I got it sorted somehow by thread sleeping only to be told by a friend that its basically "cheating" but I had to submit it yesterday, and while its "cheating" it got the code to work as I wanted.

But i'll definitely look into other ways of doing it in the future.
 
Back
Top Bottom