Java – language level threads

I'm reading about threads, and many books say that Java supports language level threads, and through Java util. The concurrent package supports high - level threads

What does it mean to support threads at the language level?

I think Erlang is a language that supports language level threads

Solution

Supporting threading at the language level means that the language provides first-class support for multithreading, rather than secondary support only through class libraries

In Java, the language level uses synchronized and volatile keywords to support threads The use of monitor and volatile fields is a relatively low-level thread construct - higher-level constructs, such as general locks, barriers, threadpools, and concurrent collections, can be found in Java util. Found in the concurrent package, as well as low-level atomic operations

Threads in Java are more than just a few keywords in the language JAVA memory model requires the result of multi-threaded memory access, for example, when the changes of one thread are visible to other threads This ensures that properly written threaded programs run as expected, regardless of the underlying architecture (instruction reordering, cache consistency policies, etc.)

The original Java class library provides access to Java Lang. thread thread thread support, representing a thread, and starting from JDK 1.2, Java Lang. ThreadLocal represents thread local variable The original JDK also includes the abstract concept of executable objects - Java lang.Runnable. Concurrency tools extend this with callable and future, which makes it much easier to create asynchronous results than to code only with low-level structures

Although you can use volatile, synchronized and runnable (as before JDK 1.5), the classes provided by concurrency tools make it easier to write threaded programs and more likely to make them correct

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
分享
二维码
< <上一篇
下一篇>>