Write a Java/Swing program with the following descriptions (Also See Figure):
NAME
coreadServer -
Concurrent Readers Server.
coreadClient -
Concurrent Readers Client.
SYNOPSIS
java
coreadServer
java coreadClient
DESCRIPTION
Ø The
coreadClient program connects to the coreadServer
with a tcp socket S and
> creates n threads.
Each thread i, i= 1, 2,.., n sleeps a random amount of time T,
where T <= n seconds and when it wakes up it performs the following steps:
· Change its status to from Sleep to Active.
· Reads 128 characters from InputFile.
If there is no more data to read
Change its status to Terminated and exit.
Else use socket S to send the data that have been read.
· Sleeps 3 seconds and then:
§ Increments its read counter.
§ Change its status from Active to Sleep.
The coreadClient Swing interface has three areas:
Input arguments area: to enter the values of:
<n> <InputFile> <RemoteHost> <Port>
Information area: Have n rows, one row for each thread.
Each raw displays the following information for the associated
thread:
-
Status: has three
values Sleep/Active/Terminated
-
Read Counter: to display the number of reads.
Control area: has four buttons:
-
Start: to start the threads (the button becomes insensitive
after the start)
-
Suspend: to suspend all threads.
-
Resume: to resume the suspended threads.
- Quit: to exit (the button becomes sensitive only when all threads are terminated).
Ø The coreadServer program creates a server tcp socket R, displays the socket port number, reads from R and saves the received data in the OutputFile.
The coreadServer Swing
interface has
three areas:
Input arguments area:
To enter the value of
the <OutputFile>
Information area: contains the following components:
-
Server Information: to display the host and port information
of the R.
-
Progress Bar: to show the progress of receiving the
file.
Control area:
has two buttons:
-
Start: to start the Server (the button becomes insensitive after
the start)
-
Quit: to exit (the button becomes sensitive when all coreadClient threads are terminated).

