私はマルチスレッドと本当に混乱しています。私はこの事実を知っている
「スレッド化は予測不可能です」
この事実は、スレッドの同じ Priority に対してのみ保持されますか? そうでない場合、スレッドの優先度を設定する必要は何ですか。
つまり、次のコードを想定しています。
public class Threadsync implements Runnable{
    Thread t;
    String str;
    public Threadsync(String name)
    {
        this.str=name;
        this.t=new Thread(this,name);
        this.t.start();
        this.t.setPriority(10);
    }
    public void run()
    {
        System.out.println("hello "+str);
    }
    public static void main(String[] args)
    {
        new Threadsync("thread1");       //1
        new Threadsync("thread2");       //2
        System.out.println("world");     //3 
    }
}
これは私のコードで、hello thread1 world hello thread2 として出力されました。
スレッド1とスレッド2について混乱はありませんが、スレッド2がメインスレッドよりもほぼ2倍の優先度を持っているにもかかわらず、スレッド2がメッセージworldを出力する前にメインスレッドがメッセージを出力するのはなぜですか。hello thread2前もって感謝します 。詳細な説明は非常に高く評価されます