SRL Archive - Java Help and Tutorials

how do i read vars between threads


g0tp0t

2010-11-11 17:15:59

i have my rsbot script and i added a thread to watch how many box traps wer setup. it it going to need to know which box traps are mine, so it has to know where i set the traps. i set traps in the parent thread. when i set a trap the parent thread records the exact location of where i set the trap. the child thread needs to see the locations i set traps on so it knows which traps are mine.

i hope that makes sense.

g0tp0t

2010-11-11 17:34:00

i know that i can create a new variable in the child thread and assign it the parent threads class. that way i can access the variable but im not sure that it wont make a new instance of my script… if it does then ill have 4 new scripts running every second. i dont want that.

EDIT: this is what i mean, the parent threads class is p0tsRedChins, the child is RedChinsWatcher

					Point[] boxspots;
P0tsRedChins rc = new P0tsRedChins();
boxspots = rc.boxSpots;
if (t.getItem().getID() == caughtID){
for (int ii =0 ; ii >= boxspots.length ; ii++) {
if (t.getLocation() == new RSTile(boxspots[ii].x, boxspots[ii].y)) {
}

}
}
return false;

Naike

2010-11-18 19:16:37

Ask on Rsbot? :s

mormonman

2010-11-18 20:19:20

You should just make the variable a global var of your script class so that you can call on it with every thread.