In Java, CPU cores can cache variables in their registers, meaning that in a multi-threaded application, each core might see a different value for the same variable, which can be a source of bugs. To prevent this behaviour, you can mark the variable volatile
e.g:
private volatile int x;
Does swift also have this CPU caching behaviour, and if so, is there an equivalent keyword to Java's volatile
to prevent it?