Does Swift have processor caching like Java?

In Java, CPU cores can cache variables in their registers, which means that in a multi-threaded application, each core can see a different value for the same variable, which can be a source of errors. To prevent this behavior, you can mark a variable volatilefor example:

private volatile int x;

Is this CPU caching behavior fast, and if so, is there an equivalent Java keyword volatileto prevent it?

+4
source share

Source: https://habr.com/ru/post/1695588/


All Articles