Java Reference
In-Depth Information
catch(IOException ioEx)
{
ioEx.printStackTrace();
}
}
public void run()
{
String request = "";
do
{
request = input.nextLine();
if (request.equals("1"))
{
item.takeOne();//If none available,
//wait until resource(s)
//available (and thread is
//at front of thread queue).
output.println("Request granted.");
}
}while (!request.equals("0"));
try
{
System.out.println(
"Closing down connection…");
client.close();
}
catch(IOException ioEx)
{
System.out.println(
"Unable to close connection to client!");
}
}
}
All that remains to be done now is to produce the code for the ConsumerClien t
class. However, the required code for this class is very similar in structure to that of
MultiEchoClient from Sect. 3.3 (as, indeed, it would be to most client programs),
and so production of this code is one of the exercises at the end of the chapter. In the
meantime, the screenshots in Figs. 3.6 and 3.7 show example output from
ResourceServer and two ConsumerClient s.
Search WWH ::




Custom Search