次のリンクに関連する質問があります。Threadstart()とRunnable run()の違いは何ですか。
この質問では、実行可能なオブジェクトを作成し、2つの異なる方法でそれらを初期化する人を見ています。それで、これは、実行時にこれらの実行可能ファイルを他のものに渡すことができることを意味しますか?
既存のスレッドにコードを渡して、そのスレッドのループ内で実行したいと思います。私は周りを見回していましたが、私が言えることから、次のような専用の実行可能なクラスを作成する必要があります。
    public class codetobesent implements Runnable  
     {  
       public void run()  
        {   
        ..morecodehere.  
        }  
      ...insertcodestuffhere  
     }  
しかし、これをすでに実行されているスレッドに渡すにはどうすればよいですか?ゲームを作ろうとしていて、レンダラーにそのスレッドで実行してもらいたい特別なことがあるとします。このランナブルをそのスレッドに渡して、このデータを正しく実行するにはどうすればよいですか?
私のレンダリングスレッドの現在の実装は次のとおりです。チュートリアルサイトから削除しましたが、これまでのところかなりうまく機能しています。しかし、プリセットループにあるもの以上のものを実行できるように、物事をそれに渡す方法を知りたいです。
class RenderThread extends Thread 
{
private SurfaceHolder _curholder;
private UserView curview;
private boolean runrender = false; 
    public RenderThread (SurfaceHolder holder, UserView thisview)
    { //Constructor function - This gets called when you create a new instance of this object.
        curview = thisview;
        _curholder = holder;
    }
    public SurfaceHolder getThreadHolder()
    {
        return _curholder;
    }
    public void setRunning(boolean onoff) 
    {
        runrender = onoff;
    }
    @Override
    public void run() 
    {
        Canvas c;
        while (runrender)
        {
            c = null; //first clear the object buffer.
            try 
            {
              c = _curholder.lockCanvas(null); //lock the canvas so we can write to it
              synchronized (_curholder) 
              {//we sync the thread with the specified surfaceview via its surfaceholder.
                  curview.onDraw(c);
              }
            } 
            finally 
            {
              // do this in a finally so that if an exception is thrown
              // during the above, we don't leave the Surface in an
              // inconsistent state
                if (c != null) 
                {
                    _curholder.unlockCanvasAndPost(c);
                }
            }
        }
    }   
}