I've got another quick question I hope gets answered. Is the Serial library Thread Safe, like can I pass around one Serial object to several different threads without synchronization issues?
I'm trying to run one of my projects in P3D, I am trying to make interesting effects based on certain events and testing in P2D works great, but once I switch over I get this error when I click and the program crashes.
Invalid memory access of location 0x0 eip=0x921c6b50
I'm not entirely sure what's going on, but it seems to be a problem with threading, I've tried a number of things, println() throughout to try to determine where it's stopping, combining PGraphics images instead of using the main Applet one. I've hit a bit of a wall, any help is greatly appreciated.
Main Class(EffectToolkit2)
DrawableControl dc;
void setup()
{
size(600, 600, P3D);
dc = new DrawableControl(color(255), 25);
dc.start();
}
void draw()
{
}
void mousePressed()
{
dc.add(new Pulse(mouseX, mouseY, 1, 100));
}
DrawableControl
public class DrawableControl extends Thread
{
private color background;
private int ms;
private ArrayList<IDrawable> list;
public DrawableControl(color background, int ms)
{
this.background = background;
this.ms = ms;
list = new ArrayList<IDrawable>();
}
public void run()
{
while(true)
{
if(list.size() != 0)
{
for(int i = 0; i < list.size(); i++)
{
if(list.get(i).step())
{
list.remove(i);
}
}
try
{
Thread.sleep(ms);
}
catch(Exception e)
{
e.printStackTrace();
}
background(background);
}
}
}
public void add(IDrawable id)
{
list.add(id);
}
}
IDrawable
public interface IDrawable
{
public boolean step();
}
Pulse
public class Pulse implements IDrawable
{
private int x;
private int y;
private int currentRadius;
private int maxSteps;
public Pulse(int x, int y, int startRadius, int maxSteps)