Okay, so I have an issue that I have finally narrowed down to multi-threading
issues.
I have a loader page that has a worker thread to process a csv file and
store the results into a list declared as:
List batchLines = Collections.synchronizedList(new
CopyOnWriteArrayList<BatchLine>());
Each BatchLine object is a row in the csv file that was processed.
I also have a pageableListView on the page that uses the BatchLine List to
update itself. I use a
AjaxSelfUpdatingTimerBehavior which will update the pageableListView every
two seconds. The problem is, if I am on this page in one browser tab, and
the workerthread is running, and the page is updating, and then at the same
time I open another instance of the application in another tab of the same
browser, the thread loses focus of this List. I know this because I print
out the size of the list, and it stays the same when I open a new instance.
I first had the List batchLines Global, but now I pass it as a parameter to
keep it local to each method. When it was global, I had to mark it transient
for serializable issues. The issue with this is the page would crash when I
opened a new tab with another instance of the application.
What can I do to prevent this?
issues.
I have a loader page that has a worker thread to process a csv file and
store the results into a list declared as:
List batchLines = Collections.synchronizedList(new
CopyOnWriteArrayList<BatchLine>());
Each BatchLine object is a row in the csv file that was processed.
I also have a pageableListView on the page that uses the BatchLine List to
update itself. I use a
AjaxSelfUpdatingTimerBehavior which will update the pageableListView every
two seconds. The problem is, if I am on this page in one browser tab, and
the workerthread is running, and the page is updating, and then at the same
time I open another instance of the application in another tab of the same
browser, the thread loses focus of this List. I know this because I print
out the size of the list, and it stays the same when I open a new instance.
I first had the List batchLines Global, but now I pass it as a parameter to
keep it local to each method. When it was global, I had to mark it transient
for serializable issues. The issue with this is the page would crash when I
opened a new tab with another instance of the application.
What can I do to prevent this?