threadでrunとstartの違い


start vs run


通常、threadを継承または実装するとrun()メソッドが実装されます.
ではrunを使うのですか?
public class RunThreads {
    public static void main(String[] args) {
        RunThreads runThreads = new RunThreads();
        runThreads.runBasic();
        
    }
    public void runBasic(){
		Worker a = new Worker();
        Worker b = new Worker();
        
        System.out.println("current thread:"+Thread.currentThread().getName());
        a.start(); a.start(); b.start(); b.start()
        
        try{
        	a.join(); b.join();
        } catch(InterruptedException e){
        	
        }
        

    }

}
上の実行結果は何ですか.
runnable startにアップグレードします.オブジェクトの場合は、もう一度上に移動するため、例外が発生します.
上のコードでは
a.run()、a.run()、b.run()、b.run()に変更したらどうですか.
実際には作成されますが、ねじの公製情報はrunnable状態に含まれません.
結果は.
current thread: main
thread: main
thread: main
thread: main
thread: main
結果は次のとおりです.
要するに.
start()メソッドは,各スレッドを実行できるメソッドと見なすことができる.