I have just joined, since I encountered a problem in a small personal project I have. To put it simple, the program is a very primitive web server that you can share files with (doesn´t host websites, it just shares stuff). It has a simple gui that helps you to, say, shut it down. You can also, or rather will be able to, read logs of what has happened and so on. And this is where my issue is.
I have made my own logging system. It doesn´t involve any file IO, it will just list the different events in a window. So if someone connects and they, say, download a file it will appear in the gui automatically. Very simple, really, but there is a possible threading issue in it. Since the application is multithreaded, entries in the log will be added from many threads. Everytime an entry is added the gui will be updated, but from what I have read, this shouldn´t be done from several threads. So one idea is to simply use the SwingUtilities class to make so the gui is updated in its own thread. BUT this would also mean that if something is added while something is updated, the list may not present accurate data. Is this a real problem or just another case of a noob programmer complicating everything for himself ? Is there some way I can check if this is a real problem? And if it is a problem, what would the best way to deal with it be?
In case it matters, there will be a limitation of how many entries the log will have at the same time. As I said, it is a small, personal project, so it won´t have the need to remember everything forever, and I do not want it to just use more and more memory... if that makes sense, lol.
And the reason I am making my own logger rather then using the ones already there is because I want to learn how to make one .
Ok, I am not sure, but could I simply use the invokeAndWait method in SwingUtilities to prevent any threading issues when adding data to the log? And if I´m just confusing or something, please tell me. I fully realize I may not be that good at explaining things .