Java SE NIO

NIO basic concepts Demonstrate the understanding of basic NIO ideology
  • Explain the differences in approaches between NIO and classical IO
  • Enumerate the main usages of NIO (like non-blocking IO)
Buffers Show ability to manipulate ByteBuffer (specific functions for HeapByteBuffer, DirectByteBuffer and MappedByteBuffer are not covered)
  • Be able to write code that uses buffers:
    • Create ByteBuffer
    • Add data to buffer
    • Remove data from buffer
  • Be able to use each buffer's parameter:
    • position
    • limit
    • capacity
  • Explain why 0 <= mark <= position <= limit <= capacity is true in all cases
Channels Display understanding of channels
  • Explain the purpose of using channels
  • Describe the purpose of basic channel interfaces and classes:
    • Channel
    • ReadableByteChannel
    • WritableByteChannel
    • ByteChannel
    • FileChannel
    • SocketChannel
    • DatagramChannel
  • Write code to construct and use FileChannel and SocketChannel:
    • Create channels:
      • RandomAccessFile.getChannel()
      • Socket.getChannel()
    • Write data to channel:
      • WritableByteChannel.write(ByteBuffer src);
      • Note that write operation might not write all the buffer during one writing loop.
    • Read data from channel:
      • ReadableByteChannel.read(ByteBuffer dst);
      • Note that read operation might not fill all the buffer during one reading loop.
    • Close channel
    • Handle channels' exceptions
Selectors This category covers questions about selectors - an approach to handle large number of reading/writing channels simultaneously.
  • Give usage description for basic classes:
    • Selector
      • Opening selector
      • Selecting keys:
        • Use Selector.select() to get ready selection keys
        • Explain difference between Selector.select() and Selector.select(int)
      • Be able to stop key selection process using wakeUp()
      • Closing selector
    • SelectableChannel
      • Bind channel to Selector in different modes:
        • SelectionKey.OP_ACCEPT
        • SelectionKey.OP_CONNECT
        • SelectionKey.OP_READ
        • SelectionKey.OP_WRITE
        • Be able to use the appropriate mode in a given situation
    • SelectionKey
      • Explain what SelectionKey is used for
      • Use SelectionKey.attach(Object) and SelectionKey.attachment() to manipulate SelectionKey's specific data
    • Be able to write code that uses them
  • Explain the difference SelectableChannel's blocking and non-blocking modes.
    Be able to choose the most appropriate mode in a given situation.
  • Explain why selectors can be scaled (no need to use a thread per connection)

你可能感兴趣的:(java,thread,socket)