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.nio.channels.spi

Class AbstractInterruptibleChannel

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Channel, InterruptibleChannel
    Direct Known Subclasses:
    FileChannel, SelectableChannel

    public abstract class AbstractInterruptibleChannel
    extends Object
    implements Channel, InterruptibleChannel
    Base implementation class for interruptible channels.

    This class encapsulates the low-level machinery required to implement the asynchronous closing and interruption of channels. A concrete channel class must invoke the begin and end methods before and after, respectively, invoking an I/O operation that might block indefinitely. In order to ensure that the end method is always invoked, these methods should be used within a try ... finally block:

     boolean completed = false;
     try {
         begin();
         completed = ...;    // Perform blocking I/O operation
         return ...;         // Return result
     } finally {
         end(completed);
     }

    The completed argument to the end method tells whether or not the I/O operation actually completed, that is, whether it had any effect that would be visible to the invoker. In the case of an operation that reads bytes, for example, this argument should be true if, and only if, some bytes were actually transferred into the invoker's target buffer.

    A concrete channel class must also implement the implCloseChannel method in such a way that if it is invoked while another thread is blocked in a native I/O operation upon the channel then that operation will immediately return, either by throwing an exception or by returning normally. If a thread is interrupted or the channel upon which it is blocked is asynchronously closed then the channel's end method will throw the appropriate exception.

    This class performs the synchronization required to implement the Channel specification. Implementations of the implCloseChannel method need not synchronize against other threads that might be attempting to close the channel.

    Since:
    1.4
    • Constructor Detail

      • AbstractInterruptibleChannel

        protected AbstractInterruptibleChannel()
        Initializes a new instance of this class.
    • Method Detail

      • implCloseChannel

        protected abstract void implCloseChannel()
                                          throws IOException
        Closes this channel.

        This method is invoked by the close method in order to perform the actual work of closing the channel. This method is only invoked if the channel has not yet been closed, and it is never invoked more than once.

        An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.

        Throws:
        IOException - If an I/O error occurs while closing the channel
      • isOpen

        public final boolean isOpen()
        Description copied from interface: Channel
        Tells whether or not this channel is open.

        Specified by:
        isOpen in interface Channel
        Returns:
        true if, and only if, this channel is open
      • begin

        protected final void begin()
        Marks the beginning of an I/O operation that might block indefinitely.

        This method should be invoked in tandem with the end method, using a try ... finally block as shown above, in order to implement asynchronous closing and interruption for this channel.

      • end

        protected final void end(boolean completed)
                          throws AsynchronousCloseException
        Marks the end of an I/O operation that might block indefinitely.

        This method should be invoked in tandem with the begin method, using a try ... finally block as shown above, in order to implement asynchronous closing and interruption for this channel.

        Parameters:
        completed - true if, and only if, the I/O operation completed successfully, that is, had some effect that would be visible to the operation's invoker
        Throws:
        AsynchronousCloseException - If the channel was asynchronously closed
        ClosedByInterruptException - If the thread blocked in the I/O operation was interrupted

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/nio/channels/spi/AbstractInterruptibleChannel.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