Multithreading

Hello,

Is there any way to create multiple threads which draw on the same canvas simultaneously?

The only way I can think of is to capture the canvas object and associate it with multiple classes simultaneously.

I assume that this is not recommended, however … Is this a really bad idea, or has someone tried this (or something similar) before?

Any thoughts?

Thanks!
Charles

It is a bad idea indeed. Even from multiple threads, you have to synchronize access to your canvas (no concurrent drawing) and do a heck of a lot other things which might or might not work, depending on the driver-version is installed on the system.

Just use 1 render-thread and buffer your render-calls in your other threads, executing them sequentially on the render-thread.

renderOps = new Runnable(){
  public void run() {
      gl.glWhatever(...);
  }
}

renderThread.addRenderOps(renderOps);

Needless to say you have to design this framework yourself.

Figured the response would be something like that … but hey, you never know as a noob!

Thanks very much for answering!