Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.
java.util.concurrent

Interface ForkJoinPool.ManagedBlocker

  • Enclosing class:
    ForkJoinPool

    public static interface ForkJoinPool.ManagedBlocker
    Interface for extending managed parallelism for tasks running in ForkJoinPools.

    A ManagedBlocker provides two methods. Method isReleasable must return true if blocking is not necessary. Method block blocks the current thread if necessary (perhaps internally invoking isReleasable before actually blocking). These actions are performed by any thread invoking ForkJoinPool.managedBlock(java.util.concurrent.ForkJoinPool.ManagedBlocker). The unusual methods in this API accommodate synchronizers that may, but don't usually, block for long periods. Similarly, they allow more efficient internal handling of cases in which additional workers may be, but usually are not, needed to ensure sufficient parallelism. Toward this end, implementations of method isReleasable must be amenable to repeated invocation.

    For example, here is a ManagedBlocker based on a ReentrantLock:

     class ManagedLocker implements ManagedBlocker {
       final ReentrantLock lock;
       boolean hasLock = false;
       ManagedLocker(ReentrantLock lock) { this.lock = lock; }
       public boolean block() {
         if (!hasLock)
           lock.lock();
         return true;
       }
       public boolean isReleasable() {
         return hasLock || (hasLock = lock.tryLock());
       }
     }

    Here is a class that possibly blocks waiting for an item on a given queue:

     class QueueTaker<E> implements ManagedBlocker {
       final BlockingQueue<E> queue;
       volatile E item = null;
       QueueTaker(BlockingQueue<E> q) { this.queue = q; }
       public boolean block() throws InterruptedException {
         if (item == null)
           item = queue.take();
         return true;
       }
       public boolean isReleasable() {
         return item != null || (item = queue.poll()) != null;
       }
       public E getItem() { // call after pool.managedBlock completes
         return item;
       }
     }
    • Method Detail

      • block

        boolean block()
                      throws InterruptedException
        Possibly blocks the current thread, for example waiting for a lock or condition.
        Returns:
        true if no additional blocking is necessary (i.e., if isReleasable would return true)
        Throws:
        InterruptedException - if interrupted while waiting (the method is not required to do so, but is allowed to)
      • isReleasable

        boolean isReleasable()
        Returns true if blocking is unnecessary.

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/util/concurrent/ForkJoinPool.ManagedBlocker.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut