I am trying to figure out how to save my server state by sending it to a JGroups cluster whenever there is an update.
For this purpose I am using the following while loop in my Server's main:
while (true) {
if (updated) {
continue;
} else {
updateState(auctions);
}
}
And the function that I use to send the data to my cluster:
public static void updateState(ArrayList<Auction> auctions) throws Exception {
Message message = new Message(null, null, auctions);
channel.send(message);
updated = true;
}
I also use a setter for updated
that changes it to false
whenever there is a change on my main array list.
Server wouldn't enter the else condition even if updated == false
, unless I replace continue;
with a random System.out.println()
. I find it really strange. Any idea why would this happen?