jPCT-AE - a 3d engine for Android > Bugs

Loader - thread safe

(1/2) > >>

Thomas.:
Is Loader thread safe? I tried to load objects in many threads for more speed, but something is wrong...

My test case
http://dl.dropbox.com/u/26148874/TestProject.rar

EgonOlsen:
Loader should be thread safe. But your threading code is strange. You aren't doing any multi-threading in it (because you are calling run() instead of start()) and if you were, you aren't waiting for the loaders to finish. Have you tried something like


--- Code: ---List<MyLoader> loaders=new ArrayList<MyLoader>();
for (int i = 0; i < cpus; i++) {
MyLoader loader = new MyLoader();
loaders.add(loader);
loader.start();
}

for (MyLoader loader:loaders) {
try {
loader.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

--- End code ---

instead?

Thomas.:
Oh sorry, I looked at the code and I found one more bug :-[ It seems compile is done when object is rendered, is possible to do it when is called method Object3D.compile() or maybe Object3D.compile(FrameBuffer)? GPU can be control by one thread, so maybe it not possible...

EgonOlsen:
No, not possible. It has to happen in the thread that is associated with the gl context.

Thomas.:
I got this message when I was loading objects


--- Code: ---01-30 00:27:54.383: W/System.err(929): java.util.ConcurrentModificationException
01-30 00:27:54.383: W/System.err(929): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:792)
01-30 00:27:54.383: W/System.err(929): at java.util.HashMap$KeyIterator.next(HashMap.java:819)
01-30 00:27:54.383: W/System.err(929): at java.util.HashSet.<init>(HashSet.java:76)
01-30 00:27:54.383: W/System.err(929): at com.threed.jpct.TextureManager.getNames(TextureManager.java:413)
01-30 00:27:54.383: W/System.err(929): at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:136)
01-30 00:27:54.383: W/System.err(929): at com.threed.jpct.Loader.loadSerializedObjectArray(Loader.java:108)
01-30 00:27:54.383: W/System.err(929): at cz.chladek.mygame.util.ObjectLoader.loadObject(ObjectLoader.java:969)
01-30 00:27:54.383: W/System.err(929): at cz.chladek.mygame.util.ObjectLoader.access$3(ObjectLoader.java:955)
01-30 00:27:54.383: W/System.err(929): at cz.chladek.mygame.util.ObjectLoader$LoaderCore.run(ObjectLoader.java:206)

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version