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.




7 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
  5. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java training in Chennai

    Java training in Bangalore

    ReplyDelete
  6. I appreciate that you produced this wonderful article to help us get more knowledge about this topic.
    I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!


    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete