Question about multithread and P2D renderer problem

edited December 2014 in Using Processing

Hi there! I'm writing an interactive art piece in Processing 2.2.1 64 bit on Linux (Mint). The problem I'm running into is that when I add a second thread by extending the Thread class, the P2D render doesn't work anymore, which is really hurting my frame rate. From what I've been able to glean, Processing won't use either of the GL renderers if you've got a second thread, apparently because the second thread creates another PApplet, which borks the whole thing up for GL. This happens when I try it on Windows 8.1, so it's apparently not a Linux thing. I should clarify that my second thread does behind the scenes stuff, and doesn't actually draw anything.

Does anyone know of a way to make that second thread not try to start its own renderer, or any other way to get around this limitation so that I can get P2D going again? The only thing I can think of is to make a Python script that passes the info to my Processing sketch, but I'm not sure if there's a good blob detection library for Python, and I'd rather keep it under one roof.

I'm not in front of my computer, but if people think it's important, I can put the specific exception that's being thrown. Advice would be appreciated! There's a show coming up next Thursday, and my piece would really benefit from this second thread staying in place.





  • You'll have much better luck if you post an MCVE - not your whole project, just a small example that shows what you're talking about.

  • I add a 2nd Thread by extending the Thread class,...
    Does anyone know of a way to make that 2nd Thread not try to start its own renderer,...

    Java Thread instances are agnostic. They won't start things like renderers by themselves: [-X

    Perhaps you're using wrong technical terms to describe your actual problem? You give me the impression that you're actually instantiating another PApplet, which indeed instantiates its own Thread and JFrame internally.
    In my experience, we can have as many PApplet instances, but only 1 of them can use an OpenGL renderer! :-SS

Sign In or Register to comment.