First, I have to code to
java 1.4 as that is the version available on our systems (Can't upgrade). So I created an application that monitors several things at once on our systems and am in the processing of creating a server that will listen for socket connections from this application to post that information in a JTextArea(Using System.out.println(); for
testing). I used most of the code available here (I'll repost it here for clarity) InFormit.
The following is the code I used to create the server.
The request queue
The
thread requester
and finally the interface
Now I start it all from main and my package is name popup2
ALL THE CODE AFTER THIS POINT IS HAND JAMMED. I have no way of moving it over via copy/paste
There is more going on in main, but all it does is start various threads based on information that it reads from a config. These threads are what reports to the server, I'll give an example of one. The next part is where I implement RequestHandler
Here is my output flusher. It's a class that I created to send a
string from one of my other classes to the output socket.
And finally here is an example of a class that is sending information to the FlushOutput class, multiple threads of these will be opened and connected to the abstract server on an as needed basis. The parser is actually about 250 lines of code, but I'll just post the relevant part here. The final product of most of the code is irrelevant other than it's a String.
So what happens when I run this is everything compiles and runs as expected with one little problem. It prints the first thread to call FlushOuput to the Request handler then nothing. I get messages to my terminal that look like this:
Recieved a new connection from "hostname": hostname
Found an available thread!
Shutting down....
Shutting down the request threads...
[0]: Attempting to kill thread
[1]: Attempting to kill thread
When it should look like this and it does for the first instance after that it just repeats the previous lines over and over.
Recieved a new connection from "hostname": hostname
Found an available thread!
Shutting down....
Shutting down the request threads...
[0]: Attempting to kill thread
[1]: Processing Request...
[1]: Attempting to kill thread
[0]: Thread shutting down...
[In the READER]
[1]: Finished Processing Request
[1]: Thread shutting down