Multithread Question

Problems with Canvas, OpenGL, etc...

Multithread Question

Postby tttcowan » Wed Nov 10, 2010 5:40 pm

Hi,

I've got two threads setup currently, the glthread and gamephysics thread. I need to be setting a "drawque" object within the glthread from the gamephysics thread which contains pointers to textures which need to be drawn... I was wondering whether it's possible, rather than to synchronise a load of methods within in the glthread, but to have a method within the gamephysics thread which implements runnable and is then run on the glthread directly... Would this prevent the original problem of an object being accessed and altered by two threads at a time? Basicly, when you set something to be run on another thread will it wait until its finished running the method it's currently running... Thus solving the problem with syncronizing.

I hope that makes sense and thanks a lot.
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Top

Re: Multithread Question

Postby moblcade.com » Thu Nov 11, 2010 12:02 am

I'm not 100% I know what you are trying to explain here, but I think what you're saying is that you want to implement a Runnable that you dispatch to run on the GLthread so you can avoid having to synchronize. You could do this simply by calling your "UpdatePhysics" method within the onDraw event of your GL View. I will say however is that all you'll probably accomplish here is pushing the synchronization to another part of your program. Eventually you are going to have to deal with thread synchonization whether it be between the physics system updating the view system or input and physics. Don't forget that you'll probably have a sound system eventually.
moblcade.com
Junior Developer
Junior Developer
 
Posts: 19
Joined: Tue Sep 07, 2010 6:31 pm

Re: Multithread Question

Postby tttcowan » Thu Nov 11, 2010 11:16 am

Thanks for that, and yes that was what I was asking... Perhaps the idea of going to the gamethread from the opengl thread via a runnable would work better thinking about it. Thanks again anyway!
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests