From 80902692c3e9615cf0b9ea042ce5fdd38b98aa49 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Jun 2013 10:40:17 +0200 Subject: CLContext.release: Avoid 'concurrency map modify exception' --- src/com/jogamp/opencl/CLContext.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index e3b83ae7..c3bd0e3f 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -52,6 +52,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -506,11 +507,14 @@ public class CLContext extends CLObjectResource { release(memoryObjects); release(samplers); - for (List queues : queuesMap.values()) { - release(queues); + synchronized(queuesMap) { + final Collection> queuesList = queuesMap.values(); + for( Iterator> queuesI = queuesList.iterator(); queuesI.hasNext(); ) { + release(queuesI.next()); + } } - }finally{ + } finally { int ret = platform.getContextBinding().clReleaseContext(ID); checkForError(ret, "error releasing context"); } -- cgit v1.2.3