我们如何在 libgdx 中实现多线程?
我尝试过:
new Thread(new Runnable() {
@Override
public void run() {
// do something important here, asynchronously to the rendering thread
final int result = 10;
// post a Runnable to the rendering thread that processes the result
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
Array<Integer> results = new Array<Integer>;
Gdx.app.log("Thread1", "Worked");
results.add(result);
}
});
}
}).start();
我已阅读here这是官方的。但它没有告诉我具体如何访问数组。
如何获取结果?通过postRunnable
最佳答案
您可以对 Runnable 进行子类化,并将数组保留为该新子类中的成员,这里对此方法有一个很好的解释 https://stackoverflow.com/a/7762490/4802055
关于java - libgdx - 如何访问 postRunnable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29705338/