Java – does using volatile only make sense in multiprocessor systems?

Using volatile only makes sense in multiprocessor systems Is this wrong?

I'm trying to learn thread programming, so if you know any good articles / PDF... I like things that mention how the operating system works, not just the syntax of the language

Solution

Volatile is used to ensure that all threads see the same copy of data If there is only one thread reading / writing field, it does not need to be volatile It will work well, just a little slow

In Java, you don't have much visibility into processor architecture. You usually talk about threading and multithreading

I suggest Java concurrency in practice, which is very good regardless of your level of knowledge, http://www.javaconcurrencyinpractice.com/

The whole point of using Java is that you don't need to know most of the details of how threads work If you learn a lot of things you don't use, you may forget it

These are the Java compiled by programming house for you - does it make sense to use volatile only in multiprocessor systems? I hope this article can help you solve Java - does using volatile only make sense in multiprocessor systems? Program development problems encountered.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>