اتمی
اتمی به چه معناست؟ Atomic یک جعبه ابزار از کلاس های بسته متغیر java.util.concurrent.atomic است که به نوشتن الگوریتم های قفل و بدون انتظار با زبان جاوا کمک می کند. الگوریتمی که فقط به رشتههای جزئی برای پیشرفت ثابت نیاز دارد، بدون قفل است. در یک الگوریتم بدون انتظار، همه رشتهها به طور مداوم پیشرفت میکنند، حتی در موارد شکست یا تأخیر رشته. الگوریتمهای بدون قفل و انتظار نیز به عنوان الگوریتمهای غیر مسدود کننده شناخته میشوند. الگوریتمهای غیر مسدود کننده برای زمانبندی فرآیند و رشته در سطوح سیستم عامل و ماشین مجازی جاوا استفاده میشوند.Bedan اتمی را توضیح می دهد همه کلاس های بسته java.util.concurrent.atomic در نام خود پیشوند 'atomic' دارند. انواع مختلفی از متغیرهای اتمی در بسته java.util.concurrent.atomic موجود است، از جمله: AtomicBoolean AtomicInteger AtomicIntegerArray AtomicIntegerFieldUpdater AtomicLong AtomicLongArray AtomicLongFieldUpdater AtomicReferenceدر زبان جاوا، همگام سازی و همگام سازی قفل کردن مختصات فقط اجازه دسترسی به فیلدهای اشتراک گذاری را می دهد. متغیرهای محافظت شده توسط قفل تغییرات این رشته برای رشته بعدی قابل مشاهده است، اما فقط پس از اینکه نخ قفل را آزاد کرد. یک مثال سناریویی است که در آن نخ A یک قفل را نگه می دارد. A فقط می تواند به متغیرهای محافظت شده توسط این قفل دسترسی داشته باشد و تغییراتی در آنها ایجاد کند. اگر رشته B این قفل را بعد از A نگه دارد، آنگاه فقط B می تواند تغییرات A را روی متغیرهای محافظت شده توسط آن قفل خاص مشاهده کند. مشکل اصلی قفل کردن زمانی رخ میدهد که B تلاش میکند قفلی را که توسط A نگه داشته شود به دست آورد. در این حالت، B مسدود میشود تا منتظر بماند تا قفل در دسترس باشد. الگوریتم های غیر مسدود کننده این مشکل را حل می کنند. هدف اصلی ساخت کلاسهای اتمی، پیادهسازی ساختارهای داده غیرانسدادی و کلاسهای زیرساخت مرتبط با آنها است. کلاس های اتمی جایگزینی برای java.lang.Integer و کلاس های مرتبط نیستند. اکثر کلاس های بسته java.util.concurrent از متغیرهای اتمی به جای همگام سازی، مستقیم یا غیرمستقیم استفاده می کنند. از متغیرهای اتمی نیز برای دستیابی به توان عملیاتی بالاتر استفاده می شود که به معنای عملکرد بالاتر سرور برنامه است.
Atomic
What Does Atomic Mean? Atomic is a toolkit of variable java.util.concurrent.atomic package classes, which assist in writing lock and wait-free algorithms with the Java language. An algorithm requiring only partial threads for constant progress is lock-free. In a wait-free algorithm, all threads make progress continuously, even in cases of thread failure or delay. Lock and wait-free algorithms are also known as nonblocking algorithms. Nonblocking algorithms are used for process and thread scheduling at the operating system and Java virtual machine levels. Techopedia Explains Atomic All java.util.concurrent.atomic package classes have the 'atomic' prefix in their names. There are different types of atomic variables available in the java.util.concurrent.atomic package, including: AtomicBoolean AtomicInteger AtomicIntegerArray AtomicIntegerFieldUpdater AtomicLong AtomicLongArray AtomicLongFieldUpdater AtomicReferenceIn the Java language, synchronization coordinates access to shared thread fields and only allows threads holding locks to access and modify variables protected by the lock. This thread’s modifications are visible to the thread that follows, but only after the thread releases the lock. An example is a scenario where thread A holds a lock. A is only able to access and make changes to variables protected by this lock. If thread B holds this lock after A, then only B can view A’s changes on the variables protected by that particular lock. The main problem with locking occurs when B attempts to acquire a lock held by A. In this case, B is blocked to wait until the lock is available. Nonblocking algorithms resolve this problem. The main purpose behind building atomic classes is to implement nonblocking data structures and their related infrastructure classes. Atomic classes do not serve as replacements for java.lang.Integer and related classes. Most java.util.concurrent package classes use atomic variables instead of synchronization, either directly or indirectly. Atomic variables also are used to achieve higher throughput, which means higher application server performance.