using the register method, i’m still struggling with implementation, i’m following your example.
String [] messages = {"Test string for secondary thread",
"Here's another message.",
"And this is yet another thread."};
int [] numbers = { 0,1,2,3,4,5,6,7,8,9,10};
int threads = 1;
void setup(){
size(200,200);
for(int i=0;i<threads;i++){
new Thread(new A(numbers)).start();
}
};
void draw(){
background(0);
fill(255);
text(frameRate,100,100);
};
class A implements Runnable {
String to_print;
int t,count = 0;;
boolean ints,intss,strings;
int [] numbers = new int[1];
String [] messages = new String[1];
A(String to_print) {
this.to_print = to_print;
};
A(Integer t) {
this.t = t;
intss = true;
};
A(String [] messages) {
this.messages = messages;
strings = true;
};
A(int [] numbers) {
this.numbers = numbers;
ints = true;
};
public void run() {
registerMethod("draw", this);
draw();
};
public void draw(){
unregisterMethod("draw", this);
try {
display();
}
catch (final AssertionError err) {
System.err.println(err);
}
};
void display(){
while(true){
count++;
//if(ints)System.out.println(count);
//displayMessages();
displayNumbers();
}
};
void displayMessages(){
if(strings)
for(int i=0;i<messages.length;i++){
String message = messages[i];
fill(255);
text(message,100,100);
}
};
void displayNumbers(){
if(ints){
//text(count,100,100);
fill(255);
rect(10,10,width-20,height-20);
//System.out.println(count);
//for(int i=0;i<numbers.length;i++){
//int number = numbers[i];
//fill(255);
//text(numbers.length,100,100);
//}
}
};
};