Tag: 减量

从java中的另一个线程访问线程的变量

我试图在java中的另一个线程中访问和修改线程的变量,我真的不知道如何做到这一点。 例如: Runnable r1 = new Runnable() { int value = 10; public void run() { // random stuff } } Runnable r2 = new Runnable() { public void run() { // of course the bellow line will not work r1.value–; // I want here to be able to decrement the variable “value” of r1 […]