Como detectar se uma variável mudou?

Eu me vi querendo fazer certas coisas nos meus programas apenas se uma variável foi alterada. Até agora, tenho feito algo assim:

int x = 1;
int initialx = x;

...//code that may or may not change the value of x

if (x!=initialx){
    doOneTimeTaskIfVariableHasChanged();
    initialx = x; //reset initialx for future change tests
}  

Existe uma maneira melhor / mais simples de fazer isso?

questionAnswers(6)

yourAnswerToTheQuestion