considera for-loopoverafunctionthattakesanarraylistreferenceandaddsanobjecttothatarraylist.iwouldnowliketoexecuteacharacharachachfuteachachfunctitition
is the ArrayList.add (methodthreadsafeifidon ' tcareaboutthesequencetheobjectsareaddedandnofunctionreadsormanipulatesanyarionyates
soionlywanttomakesurethatattheendoftheparallelcallallobjectsareaddedtothelist。
解决方案
No,it ' snot thread-safe.wrapyourlistusingcollections.synchronized list (,oruseexplicitsynchronizationwhenaccessingthrron