質問

I am having an issue in Wicket, which I think may be more related to Java.

How to I handle a class that is serializable and has a running thread when it is serialized? I am losing state of the Thread when the class is serialized and then deserialized. My Thread reference is global, but when the class comes back the reference is null and the thread is still running. The List I am using and delcared inside the main class, and passed to the runnable class remains alive but no longer gets filled by the thread. The thread is still filling a List object but I am not seeing any updates in the main class...

I am using List batchLines = Collections.synchronizedList(new CopyOnWriteArrayList());

役に立ちましたか?

解決

If your thread is running outside the page, so it should be better to reference it in your Application that is a singleton, e.g. use a map to put a unique id such as page hashCode. Just be careful about memory leaks.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top