File tree Expand file tree Collapse file tree 4 files changed +15
-8
lines changed Expand file tree Collapse file tree 4 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 1+ * .class
2+ * ~
3+ * .swp
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ else while (menuSelection != 7) {
4444 for (int i = 0 ; i < 30 ; i ++) {
4545 // make a new thread, tell it the hostname to connect to
4646 // and the command to run
47- thrd = new Thread (new ClientThread (hostName , menuSelection ));
47+ thrd = new Thread (new ClientThread (hostName , menuSelection , i ));
4848 thrd .start (); // start the thread
4949 list .add (thrd ); // add the thread to the end of the linked list
5050
Original file line number Diff line number Diff line change @@ -10,10 +10,12 @@ public class ClientThread extends Thread {
1010 int menuSelection ;
1111 String hostName ;
1212 private static Socket socket = null ;
13-
14- ClientThread (String hostName , int menuSelection ) {
13+ int threadNum ;
14+
15+ ClientThread (String hostName , int menuSelection , int threadNum ) {
1516 this .menuSelection = menuSelection ;
1617 this .hostName = hostName ;
18+ this .threadNum = threadNum ;
1719 }
1820
1921 public void run () {
@@ -33,14 +35,15 @@ public void run() {
3335 in = new BufferedReader (new InputStreamReader (socket .getInputStream ()));
3436 System .out .println ("\n Requesting output for the '" + menuSelection + "' command from " + hostName );
3537 // send the command to the server
36- out .println (Integer .toString (menuSelection ));
37- out .flush ();
38+ for (int i = 0 ; i < 25 ; i ++) {
39+ out .println (Integer .toString (menuSelection ));
40+ out .flush ();
41+ }
3842 System .out .println ("Sent output" );
3943 // read the command from the server
4044 String outputString = "hi" ;
4145 while (((outputString = in .readLine ()) != null ) && (!outputString .equals ("END_MESSAGE" ))) {
42- System .out .println (outputString );
43- System .out .println ("Input read" );
46+ System .out .println (threadNum + " " + outputString );
4447 }
4548 System .out .println ("closing" );
4649 try {
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ public void run() {
2121 BufferedReader in = new BufferedReader (new InputStreamReader (client .getInputStream ()));
2222 System .out .print ("Reader and writer created. " );
2323
24- String inString = in .readLine ();
24+ String inString ;
25+ while ((inString = in .readLine ()) == null );
2526 System .out .println ("Read command " + inString );
2627
2728 String outString = CommandExecutor .run (inString );
You can’t perform that action at this time.
0 commit comments