(PLEASE answer in "little java words" for I am learning. <Very big smile)
In my main server thread it contains a queue (of out going packets) and a client ref hashmap with id's and the ref to each new client OBJ I create. Also, this same server generates a thread which handles the packets queue which then is distributed to the hashmaps (client ref).queues (probably more info then is needed for this question.)
Any who, I need my server dispatch thread to walk the client ref hashmap and plug in the packets into each client's queue.. this same hashmap is is added to each time a client connects.. (So I'm seeing a need to syncronize)
In the main server thread syncronizing the read and write methods to the hashmap is not how I want to do this right?
Somehow which I'm not sure of I need to syncronize my queue's and hashmap.
Anyone have a good article or some code snipets to explain how to do this.
Man I was so pleased with myself How well I was creating threads and having them work sending packets back and forth to my client. Then I started thinking....
P.S. I created a 1 does all method for my queues that I think is safe code listed below...
In my main server thread it contains a queue (of out going packets) and a client ref hashmap with id's and the ref to each new client OBJ I create. Also, this same server generates a thread which handles the packets queue which then is distributed to the hashmaps (client ref).queues (probably more info then is needed for this question.)
Any who, I need my server dispatch thread to walk the client ref hashmap and plug in the packets into each client's queue.. this same hashmap is is added to each time a client connects.. (So I'm seeing a need to syncronize)
In the main server thread syncronizing the read and write methods to the hashmap is not how I want to do this right?
Somehow which I'm not sure of I need to syncronize my queue's and hashmap.
Anyone have a good article or some code snipets to explain how to do this.
Man I was so pleased with myself How well I was creating threads and having them work sending packets back and forth to my client. Then I started thinking....
P.S. I created a 1 does all method for my queues that I think is safe code listed below...