Hey guys, just finished reading my first book on Java and I'm working on a Chat Client/Server project so I can dig a little bit into streams, multi-threading, saving objects, etc.
At the moment, I'm a little puzzled.
The way I think this through in my head (and you can tell me if this is completely wrong) is when the server accepts a client,
- I want to create a separate thread for any messages that might come through (text, when people are typing back and forth).
- The other thread is constantly waiting for any Objects that are sent to the Server so I can update the Player list.
This is my code for accepting another client:
I have two inner classes that implement Runnable and have their own run() methods that are being executed by two threads.
However, the program doesn't want to initialize both threads? If I have them both in there it won't make the second thread?
If I have just one thread created in this procedure than everything works fine?
Please tell me if I'm doing something completely incorrect here. If you need more code, let me know. Keep in mind, this is my FIRST thread project.
PS: After looking this over, is the solution to have another thread constantly just doing the accepting process of clients?