From the Java language specification:
The Java β’ programming language is a universal, parallel, class-based, object-oriented language.
What is a parallel language?
This means that threads and synchronization are built into the language, and are not part of the library that you can include (e.g. PThreads for C).
Designed for parallel computing .
, , , , . .
- , , .
wikipedia
You can simply synchronize the method because Java is a parallel language. As in the document,
To synchronize a method, simply add the synchronized keyword to your ad:
public class SynchronizedCounter { private int c = 0; public synchronized void increment() { c++; } public synchronized void decrement() { c--; } public synchronized int value() { return c; } }
across
It looks like a brand of waffles ... almost none of me knows that any language will be "parallel" just because it has several primitives or syntactic sugar around threads and blocking.
See if you want to know more about concurrency and java
Source: https://habr.com/ru/post/1715539/More articles:Sleep / restart thread - c ++Does LINQ to SQL support t-sql "in" - c #TDD in a big project: where do you start? - tddHow to install ViewPlatform and update TransformGroup? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1715538/using-usehostcompilerifavailable-false-makes-vs-to-build-already-built-projects-over-and-over-again&usg=ALkJrhi3Xisedk-RTyZT9l-koSxoRrZf6QHow to safely write to a log file from two instances of the same application? - c #How to replicate and configure the Active Directory DC test - active-directoryhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1715542/using-hierarchicaldatatemplatetriggers-to-affect-controls-in-the-itemtemplate&usg=ALkJrhgVdNtA0wFOBinStDWc61T6mNLhOgHow to display part of an image using jquery? - jqueryIs there a utility for generating UDP and TCP packets from raw data in a file? - packet-captureAll Articles