I work with Threadin Javaand I get the following error: I don’t understand why ?!
the code:
import java.util.Random;
public class Test {
public static void main(String[] args) throws InterruptedException {
Vlakno sude = new Vlakno("myName");
sude.start();
sude.wait();
}
}
class Vlakno extends Thread {
private boolean canIRun = true;
private final String name;
Vlakno(String name) {
this.name = name;
}
@Override
public void run() {
while (canIRun) {
}
}
public void mojeStop() {
System.out.println("Thread "+name +" end...");
this.canIRun = false;
}
}
source
share