BOOKJAVA Telegram 4010
Thread.sleep(0) is not for free.

Небольшая заметка о том, что Thread.sleep(0) не бесплатный. Связано это с тем, что при таком вызове все еще вызывается нативный метод Thread.sleepNanos(0). А за этим методом идет выполнение метода операционной системы, и, хоть он и проводит для такого случая быстрые проверки, они замедляют систему. Поэтому стоит избегать кода:


int delay = allGood ? 0 : waitShorty;

Thread.sleep(delay);


https://mlangc.github.io/java/performance/2025/08/14/thread-sleep0-is-not-for-free.html

👉@BookJava
👍2



tgoop.com/BookJava/4010
Create:
Last Update:

Thread.sleep(0) is not for free.

Небольшая заметка о том, что Thread.sleep(0) не бесплатный. Связано это с тем, что при таком вызове все еще вызывается нативный метод Thread.sleepNanos(0). А за этим методом идет выполнение метода операционной системы, и, хоть он и проводит для такого случая быстрые проверки, они замедляют систему. Поэтому стоит избегать кода:


int delay = allGood ? 0 : waitShorty;

Thread.sleep(delay);


https://mlangc.github.io/java/performance/2025/08/14/thread-sleep0-is-not-for-free.html

👉@BookJava

BY Библиотека Java разработчика




Share with your friend now:
tgoop.com/BookJava/4010

View MORE
Open in Telegram


Telegram News

Date: |

The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.” Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. How to Create a Private or Public Channel on Telegram? The court said the defendant had also incited people to commit public nuisance, with messages calling on them to take part in rallies and demonstrations including at Hong Kong International Airport, to block roads and to paralyse the public transportation system. Various forms of protest promoted on the messaging platform included general strikes, lunchtime protests and silent sit-ins.
from us


Telegram Библиотека Java разработчика
FROM American