Hi Dw
I have a multi-threaded server that connects thousands of clients. The clients sends in data that the server must write to a text file. As there are a thousands of clients sending in data the server has about 60 texts files but the data sent by the client to the server gives a server a clue on which text file to write to. Suppose in the server side I have these two text files: "test1.txt" and "test2.txt"
Let's say the client sends <test2, testing> the server knows that it should write "testing" on test2.txt so now as there are a thousand clients it can happen that maybe 50 clients sends the same data to the server at the same time that means the threads will write to the same file simultaneously.
So how can I make it handle this all the data written by all the threads at the same time be saved to a file meaning allowing multi-threads to write to the same file simultaneously without overriding the existing text?
Thanks in advance.
Sample code of this server: www.daniweb.com/software-development/java/threads/481619/server-split-message-and-save-data-on-a-text-file