Could you advise me how to implements queue in multithreaded application.
I have to register events in my application in queue (events from all users) which I flush and save to database every 100 events to improve performance. I don't want save database log for every single user commit. I suppose commit e.x. every 100 events to database will be faster that 100 single commits. I have three ideas:
- use ThreadLocal
- use queue for single user
- use synchronized LinkedList and flush from time to time or every number of events
Do you have any other ideas? I don't use log4j because I have to save log to database - not to file, which method will the best?