I have a workerprocess which generates a continuous Text Log (until it is finished). I send this Log to a Webserver, which should store this log. At the same time it should be possible for an user to view this log in real Time by using a different Webserver interface.
Actually I have a HashMap where Key is an ID and the value is a StringBuilder where I append the Data any time there comes a new log row.
The Problem is, that any process uses this HashMap and I am afraid when there will be more simultaneous processes and many users who want to read the log.
What would be a better approach for this use case?
Since all requests to Webserver are made in different threads, problem could occur when:
StringBuilder
StringBuilder
.Easiest solution: use StringBuffer
instead of StringBuilder
, because all its methods are synchronized.