Java

ExecutorService & thread pools

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

Në vend që të krijosh thread-e me dorë, ExecutorService mban një grup thread-esh gati (thread pool) dhe ua shpërndan punët. Kur mbaron, e mbyll me shutdown().

EnglishEN

Instead of creating threads by hand, an ExecutorService keeps a group of ready threads (a thread pool) and hands out jobs to them. When you're done, close it with shutdown().

Si ta mendosh

Si një firmë dërgesash me 4 korrierë: s'punëson korrier të ri për çdo pako.

Lexoje në anglisht

Like a delivery firm with 4 couriers: it doesn't hire a new courier for every parcel.

Shembull kodijava

ExecutorService ex = Executors.newFixedThreadPool(4);
ex.submit(() -> perpuno("a.txt"));
ex.shutdown();

Terma të lidhur