This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Threaded Application won't run. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Threaded Application won Watch "Threaded Application won New topic
Author

Threaded Application won't run.

Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 99
What gives?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61066
    
  66

Perhaps an expanded definition of "won't run" might be helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4367
    
    8

Does your connect() method ever exit?
Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 99
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: 99
connect() doesn't get called because void run() is never called.
Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 99
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: 19672
    
  18

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 99
Using the same format for ChatServer i build ChatClient, both Server and Client send data but it doesn't noticeably get received.

ChatClient.java
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threaded Application won't run.