Using a thread within a subclass

edited February 2016 in Questions about Code

I am trying to to execute a thread withing a subclass, something like this:

void setup(){ testClass test = new testClass(); test.go(); } class testClass{ void go(){ thread("thing"); } void thing(){ for(int i = 0;i<30;i++){ print(i); } } }

but I get the error: There is no public thing() method in the class sketch_160201a

The actual thing I want to do this with involves an array of subclass instances, each one with different values that the thread uses. Any good ways to do this, other than:

void setup(){ testClass test = new testClass(); test.go(); } void toThread(testClass use){ use.thing(); } class testClass{ void go(){ thread("toThread"); } void thing(){ for(int i = 0;i<30;i++){ print(i); } } }

But that doesn't work because the thread() command can't pass arguments. I think there may be a way to do this with the java Thread class, but I couldn't find a good way to do this.

Tagged:
Sign In or Register to comment.