44. Explain threads blocking on I/O


Occasionally threads have to block on conditions other than object locks. I/O is the best example of this. Threads block on I/O (i.e. enters the waiting state) so that other threads may execute while the I/O operation is performed.When threads are blocked (say due to time consuming reads or writes) on an I/O call inside an object’s synchronized method and also if the other methods of the object are also synchronized then the object is essentially frozen while the thread is blocked.


Be sure to not synchronize code that makes blocking calls, or make sure that a non-synchronized method exists on an object with synchronized blocking code. Although this technique requires some care to ensure that the resulting code is still thread safe, it allows objects to be responsive to other threads when a thread holding its locks is blocked.


Note: The java.nio.* package was introduced in JDK1.4. The coolest addition is nonblocking I/O (aka NIO that stands for New I/O). Refer Q20 in Java section for NIO.




5 comments:

  1. Following various seconds the codes will look on the scanner.
    There two procedures for the automobile which produced before 1996 and immediately after 1996.



    Also visit my page; obd logger

    ReplyDelete
  2. Thеу gіve good eleсtrіc cigs wіth а lot even aԁditiοnal adѵancеments versuѕ
    new manufaсtureг.

    Also viѕit mу websіte; http://www.prnewswire.com/News-releases/v2-Cigs-coupon-codes-released-at-theecigexpertscom-183592391.html

    ReplyDelete
  3. The computer software is out there from the business site and various distributors.
    It vehicle populates the available sensor readings (PIDs).


    My homepage; obdii scan tool - -

    ReplyDelete
  4. Amazing & Great informative blog,it gives very useful practical information to developer like me. Besides that Wisen has established as Best Hibernate Training in Chennai . or learn thru Online Training mode Hibernate Online Training | Java EE Online Training. Nowadays Hibernate ORM has tons of job opportunities on various vertical industry.

    ReplyDelete