I have a thread that executes the following code:
public void run() {
try {
int n = 0;
byte[] buffer = new byte[4096];
while ((n
I had the same problem today, and this is how I fixed it, using in.ready()
:
public void run() {
String line;
// Some code
while(!Thread.currentThread().isInterrupted()){
try {
if (in.ready()) {
line = in.readLine();
}
} catch (Exception e) {
try {
Thread.currentThread().wait(500);
} catch (InterruptedException e1) {
// Do what we want when thread is interrupted
}
}
}
}