Eric Barnaba 6 years ago
parent
commit
b23fb3622b
1 changed files with 25 additions and 11 deletions
  1. 25
    11
      Client/src/main/java/SimpleShell.java

+ 25
- 11
Client/src/main/java/SimpleShell.java View File

@@ -155,21 +155,35 @@ public class SimpleShell {
155 155
                     pb.command(list);
156 156
                 }
157 157
 
158
-                // wait, wait, what curiousness is this?
159
-                Process process = pb.start();
158
+                 class ProcessThread implements Runnable{
160 159
 
161
-                //obtain the input stream
162
-                InputStream is = process.getInputStream();
163
-                InputStreamReader isr = new InputStreamReader(is);
164
-                BufferedReader br = new BufferedReader(isr);
160
+                    @Override
161
+                    public void run() {
162
+                        // wait, wait, what curiousness is this?
163
+                        try {
164
+                            Process process = pb.start();
165 165
 
166
-                //read output of the process
167
-                String line;
168
-                while ((line = br.readLine()) != null)
169
-                    System.out.println(line);
170
-                br.close();
166
+                            //obtain the input stream
167
+                            InputStream is = process.getInputStream();
168
+                            InputStreamReader isr = new InputStreamReader(is);
169
+                            BufferedReader br = new BufferedReader(isr);
171 170
 
171
+                            //read output of the process
172
+                            String line;
172 173
 
174
+
175
+                            while ((line = br.readLine()) != null)
176
+                                System.out.println(line);
177
+                            br.close();
178
+                        }
179
+                        catch(IOException ioe){
180
+                            System.out.println(ioe.getMessage());
181
+                        }
182
+
183
+                    }
184
+
185
+                }
186
+                new Thread(new ProcessThread()).run();
173 187
             }
174 188
 
175 189
             //catch ioexception, output appropriate message, resume waiting for input