这是我现在拥有的代码,不幸的是继承的类没有在单独的线程中运行我希望继承的类在单独的线程中运行。请告诉我这样做的最佳方法是什么。
问候!
主要的
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);
}
}