| Author |
Threaded Application won't run.
|
Rob Brew
Ranch Hand
Joined: Jun 23, 2011
Posts: 88
|
|
What gives?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
|
Perhaps an expanded definition of "won't run" might be helpful.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3786
|
|
|
Does your connect() method ever exit?
|
 |
Rob Brew
Ranch Hand
Joined: Jun 23, 2011
Posts: 88
|
|
|
public void run won't execute, and from that the rest of the program is started.
|
 |
Rob Brew
Ranch Hand
Joined: Jun 23, 2011
Posts: 88
|
|
|
connect() doesn't get called because void run() is never called.
|
 |
Rob Brew
Ranch Hand
Joined: Jun 23, 2011
Posts: 88
|
|
ah, hang on.
I'm using NetBeans and was actually running ChatClient when i hit run.
Goes to stand in a corner.
Ignore this please.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
Matthew is still right. Your connect() method contains a while (true) loop that only ends when an exception occurs, and therefore the entire method will only end when an exception occurs.
Other than that, you will overwrite reader and writer for every new connection. They should become local variables instead, which you then pass to the runnables:
Now each connection will have its own reader/writer pair and its own handling threads.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Rob Brew
Ranch Hand
Joined: Jun 23, 2011
Posts: 88
|
|
Using the same format for ChatServer i build ChatClient, both Server and Client send data but it doesn't noticeably get received.
ChatClient.java
|
 |
 |
|
|
subject: Threaded Application won't run.
|
|
|