這是我現在的代碼,不幸的是繼承的類不能在單獨的線程中運行我想要繼承的類在單獨的線程中運行。請告訴我這樣做的最好方法是什麼。多線程和繼承
問候!
主要
public class Main
{
public static void main(String[] args)
{
new Thread(new ClassA(country, category, false, false)).start();
}
}
A類
ClassA extends Common implements Runnable
{
volatile String country;
volatile String category;
volatile Boolean doNotReset;
volatile Boolean doNotFlash;
public ClassA(String country, String category, Boolean doNotReset, Boolean doNotFlash)
{
this.country = country;
this.category = category;
this.doNotReset = doNotReset;
this.doNotFlash = doNotFlash;
}
@Override
public void run()
{
}
}
常見
public class Common
{
Common()
{
Thread t = Thread.currentThread();
String name = t.getName();
System.out.println("name=" + name);
}
}