Using volatile Modifier
The volatile keyword indicates that a field might be modified by multiple concurrently executing threads. Marking a field as volatile would make sure that it is not cached dur¬ing the exe¬cu¬tion of a thread.
public volatile int i;
public volatile int i;
Comments
Post a Comment