Java

Virtual threads (Java 21)

Në shqip: Thread-et virtuale

ShpjegimiSQ

Thread-et virtuale (Java 21) janë thread-e shumë të lehta që JVM-ja i menaxhon vetë — mund të kesh miliona njëkohësisht. Kodi i thjeshtë „bllokues“ shkallëzohet si kodi async, pa e ndërlikuar.

EnglishEN

Virtual threads (Java 21) are very lightweight threads the JVM manages itself — you can have millions at once. Simple “blocking” code scales like async code, without the complexity.

Si ta mendosh

Si kamerierë të panumërt që s'kushtojnë pothuajse asgjë.

Lexoje në anglisht

Like countless waiters who cost almost nothing.

Shembull kodijava

try (var ex = Executors.newVirtualThreadPerTaskExecutor()) {
    for (var url : adresat) ex.submit(() -> shkarko(url));
}

Terma të lidhur