tut09_2009 - returns a null value if user input is not...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
EE3206/EE5805 Java Programming and Applications Tutorial 9 – Concurrent Programming 1. Many I/O operations are blocked I/O. For example, trying to read system input from console using the Scanner class can block the executing thread until the input is ready. Create the class BlockedReader as shown in Code 1. Write a main method in another class to test the read method of the BlockedReader . 2. Write a class NonBlockedReader by reusing the BlockedReader . The NonBlockedReader provides a non-blocking read method which immediately
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: returns a null value if user input is not ready. This read method has the same method header as that of BlockedReader . Write a main method in another class to test the read method of the NonBlockedReader . (Hints: use another thread to read inputs) - END - Code 1. BlockedReader package jtutor09; import java.util.Scanner; public class BlockedReader { Scanner scan = new Scanner(System.in); public String read() { return scan.nextLine(); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online