我实际上并不知道你是否可以声明一个类,然后在同一个类的几个对象中使用一个静态实例。更确切地说:
class State {
public:
State();
static CustomNumberDist normal_dist;
private:
int id;
};
因此,状态的每个实例都应该包含相同的CustomNumberDist实例。我编译了,但我想知道它是否有效,否则我可能会在以后遇到问题。
当我试图使用线程时,我会得到这个错误。
Can't create handler inside thread that has not called Looper.prepare()
Thread anOpenConnectionThread = new Thread(new Runnable()
{
@Override
public void run()
{
try
{
openConnection();
}