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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
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: 61648
    
  67

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: 4464
    
    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: 19760
    
  20

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threaded Application won't run.