G
Gast
Gast
ich verwende untere Methode um Objekte zu kopieren, diese Methode unten wird so von verschiedenen Stellen aufgerufen,
kann sich jemand erklären, warum ich diese Exceprion unten bekomme?
Vielen Dank,
Exception:
kann sich jemand erklären, warum ich diese Exceprion unten bekomme?
Vielen Dank,
Code:
new Thread() {
public void run() {
try {
createNewChartObject(); // in dieser Methode wird deepCopy aufgerufen
ChartUtilities.saveChartAsJPEG(file, copiedChartObject.getChart(), copiedChartObject.getWidth(), copiedChartObject.getHeight());
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}.start();
Code:
private Object deepCopy(Object o) {
ByteArrayOutputStream baos = null;
ByteArrayInputStream bais = null;
ObjectOutputStream ops = null;
try {
baos = new ByteArrayOutputStream();
ops = new ObjectOutputStream( baos );
ops.writeObject(o); // hier bekomme ich eine Exception in thread "Thread-5" java.util.ConcurrentModificationException
baos.flush();
bais = new ByteArrayInputStream( baos.toByteArray() );
return new ObjectInputStream(bais).readObject();
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
finally {
try {
if(bais != null)
bais.close();
if(baos != null)
baos.close();
if (ops != null)
ops.close();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
return null;
}
Exception:
Code:
[/coException in thread "Thread-5" java.util.ConcurrentModificationException
at java.util.ArrayList.writeObject(ArrayList.java:573)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
de]