java - InputStream reader blocking thread -
i wrote inputstream reader listen socket. code in while(!stop)
loop inside run
method of thread. reader blocks thread, , not print message.
int read = 0; byte[] buf = new byte[512]; int index = 0; try { while (!stop && (read = in.read()) != -1) { system.out.println("read loop"); buf[index++] = (byte) read; } } catch (ioexception e) { e.printstacktrace(); }
the read indeed blocks thread running if no data available.
what want read byte timeout ?
look answer in is possible read inputstream timeout?
Comments
Post a Comment