One way to create a thread is to extend the java.lang.Thread class and override its run() method. For example:
class MyThread extends Thread {
private String parameter;
public MyThread(String parameter) {
this.parameter = parameter;
}
public void run() {
while(!"exit".equals(parameter)){
System.out.println((isDaemon() ? "daemon" : " user") +
" thread " + this.getName() + "(id=" + this.getId() +
") parameter: " + parameter);
pauseOneSecond();
}
System.out.println((isDaemon() ? "daemon" : " user") +
" thread " + this.getName() + "(id=" + this.getId() +
") parameter: " + parameter);
}
public...