Hello guys...

i came across this statement on the internet "java uses Preemtive scheduling?!!!" and i have NO idea what it means.

i found 2 definitions online:

A preemptive operating system allows external interrupts ( such as timers, communication devices, etc.) to cause the task that is running to be preempted by a higher priority task.

In a non-preemptive Operating system . Each task is allow to run until it is ready to give up control (cooperative), or its alotted time expires (time sliced). No preemption is possible.

i have 2 questions

first one :in the definition of non-preemptive os, doesnt alotted time means a timer interrupt ? so its not non preemptive anymore !

second question : so i "preemptive" / "non preemptive" adjective is used for scheduling ways that the OPERATING system uses.

what does it mean to say that java uses preemtive sheduling ?! java is a language , not an operating system that has processes to schedule and run !

thank you in advance for your help.

Internally, the JVM has a thread scheduler.
How it works depends on the hardware and operating system architecture it's implemented on (so may differ) but generally it will be preemptive.

i read the link you sent me, its quite interesting , but there is somethings that i dont understand, its says :
"Java uses fixed-priority scheduling algorithms to decide which thread to execute ".

i know what thread in operating system mean, but in Java ?!!! for example, when i write a simple code. where is the thread in it ?!!

In fact every code you write is executed in a thread.
So your code is ALWAYS multithreaded, with threads internal to the JVM running next to it (things like the garbage collector, class loader, etc.).

Oh Ok..i totally understood...thank you all guys :)