Are Java threads created in user space or kernel space?

前端 未结 3 936
孤街浪徒
孤街浪徒 2021-02-03 11:04

Check this code out

    Thread t1 = new Thread(new Runnable() {

        @Override
        public void run() 
        {
            try
            {
                    


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 11:59

    Most JVMs implement threads with native, OS level threads, including the Oracle reference implementation based on OpenJDK.

    I imagine the JVMs that use 'green threads' (user space simulation of threads) would use preemptive scheduling so that an infinite loop in one thread doesn't block the other threads, but without knowledge of a particular implementation this is just speculation.

提交回复
热议问题