初心者くさいここに謝罪スレッドクラスのメソッドにアクセスできませんか?
public class Threads implements Runnable {
public String threadName;
private volatile boolean running = true;
public Threads(String name) {
threadName = name;
}
public void setoff() {
running = false; //this.running = false;
}
public void seton() {
running = true; //this.running = true;
}
public void run() {
while(this.running) {
System.out.println("running");
}
if(this.running ==false) {
System.out.println("stopped");
}
System.out.println("Thread " + threadName + " exiting.");
}
}
--endクラス
public class MainFrame extends javax.swing.JFrame {
Thread R1 = null;
public MainFrame() {
initComponents();
}
private void jbtnstartActionPerformed(java.awt.event.ActionEvent evt) {
R1 = new Thread(new Threads("Thread 1"));
R1.start();
}
}
ので、私は私のメインクラスからR1のいずれかの関数を呼び出すことができないんですか? (seton()、setoff()etc.など)
ご協力いただければ幸いです。
[ask] – Amit