Java libgdx-如何访问postRunnable

Java libgdx-如何访问postRunnable,java,multithreading,libgdx,Java,Multithreading,Libgdx,如何在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 process

如何在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();
new线程(new Runnable()){
@凌驾
公开募捐{
//在这里做一些重要的事情,异步到渲染线程
最终int结果=10;
//向处理结果的渲染线程发布Runnable
Gdx.app.postRunnable(新的Runnable(){
@凌驾
公开募捐{
数组结果=新数组;
Gdx.app.log(“Thread1”,“Worked”);
结果。添加(结果);
}
});
}
}).start();
我读过,这是官方的。但它没有具体告诉我如何访问阵列


如何访问结果?通过postRunnable

您可以将Runnable子类化,并将数组作为新子类中的一个成员保留,这里有一个很好的方法解释

我想访问数组结果。不将数据发送到线程。用要传回的数组替换数据。@Tenfour04,我要将信息从线程传递出去,而不是传递到threadrunOnUiThread()用于ANDROID活动,而不是libgdx。所以那个链接对我没用???这个链接的答案显示了如何将数据从线程传递回主线程。您可以用Gdx.app.postRunnable替换runOnUIThread。