aspose file tools
The moose likes Beginning Java and the fly likes Threaded Application won't run. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 88
What gives?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56150
    
  13

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
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threaded Application won't run.
 
Similar Threads
How do you formally disconect a client from a server?
Client disconnected from server after about 10 minutes of inactivity
Multiple client chat server
Java networking, nothing happens
I need help improving this chat server and chat client!