Results 1 to 2 of 2
Thread: listening socket in a new thread
- 10-28-2013, 10:36 AM #1
Member
- Join Date
- Oct 2013
- Posts
- 51
- Rep Power
- 0
listening socket in a new thread
Hi!
I have min-chat and that is part of client code:
Java Code:final ObjectInputStream in = new ObjectInputStream(socket.getInputStream()); final ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); // Создаем поток для чтения с клавиатуры. BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); Thread t = new Thread( new Thread() { @Override public void run() { while(! socket.isClosed()) { } } } ); line = in.readUTF(); // In this part socket input data can be delayed and it can be not printed to console immediately System.out.println(line);
So, why should i make Object streams final ?
PS Feel free to offer another way to communicate with server data to print it to console immediately
- 10-28-2013, 12:06 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Similar Threads
-
How to close this thread? (Socket listener)
By zardos in forum New To JavaReplies: 5Last Post: 03-02-2011, 11:27 PM -
Socket and how to launch thread for receiving socket messages
By newbiejava in forum New To JavaReplies: 1Last Post: 07-02-2010, 02:18 PM -
Socket Listening problem in Netbeans
By adeel109 in forum NetworkingReplies: 0Last Post: 05-06-2010, 03:21 PM -
NIO Server: listening on client's side socket
By carek in forum NetworkingReplies: 1Last Post: 12-24-2009, 08:30 AM -
best way to signal a thread that's blocking on a socket receive
By danieru in forum Threads and SynchronizationReplies: 5Last Post: 09-08-2009, 05:47 PM
Bookmarks