Skip to content

Commit 114f117

Browse files
committed
switch to wait/notify - no special reason, looks better.
1 parent a7e831d commit 114f117

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/net/sharksystem/asap/apps/testsupport/SocketFactory.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public void run() {
3131
this.remoteAddress = ASAPEncounterHelper.getRemoteAddress(socket);
3232
System.out.println("socket created");
3333
if(this.waitForConnectionThread != null) {
34-
this.waitForConnectionThread.interrupt();
34+
//this.waitForConnectionThread.interrupt();
35+
this.waitForConnectionThread.notify();
3536
}
3637
} catch (IOException e) {
3738
e.printStackTrace();
@@ -45,7 +46,8 @@ public InputStream getInputStream() throws IOException {
4546
}
4647
this.waitForConnectionThread = Thread.currentThread();
4748
try {
48-
Thread.sleep(Long.MAX_VALUE);
49+
//Thread.sleep(Long.MAX_VALUE);
50+
this.waitForConnectionThread.wait();
4951
} catch (InterruptedException e) {
5052
// great - do it again
5153
return this.getInputStream();
@@ -62,7 +64,8 @@ public OutputStream getOutputStream() throws IOException {
6264
}
6365
this.waitForConnectionThread = Thread.currentThread();
6466
try {
65-
Thread.sleep(Long.MAX_VALUE);
67+
//Thread.sleep(Long.MAX_VALUE);
68+
this.waitForConnectionThread.wait();
6669
} catch (InterruptedException e) {
6770
// great - do it again
6871
return this.getOutputStream();
@@ -79,7 +82,8 @@ public String getRemoteAddress() throws IOException {
7982
}
8083
this.waitForConnectionThread = Thread.currentThread();
8184
try {
82-
Thread.sleep(Long.MAX_VALUE);
85+
//Thread.sleep(Long.MAX_VALUE);
86+
this.waitForConnectionThread.wait();
8387
} catch (InterruptedException e) {
8488
// great - do it again
8589
}

0 commit comments

Comments
 (0)