This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi , Who is responsible for scheduling threads ??programmer by using Threads API or O.S. ??? in anther word , scheduling in java depend on real time system or depend on threads library or both?? note : i write program in java contain more than one threads and when i run the program the threads excute run method sequentially there is no interleave in the result but when i add sleep the run is interleaved so i hope i get any body explain for me why ??? Thanks a lot
[This message has been edited by Rahul Mahindrakar (edited December 12, 2000).]
deekasha gunwant
Ranch Hand
Joined: May 06, 2000
Posts: 396
posted
0
Hi Nada, Although I'm no expert still I'll just try to answer your question as per my understanding. java gives the programmer the liberty to create threads. but what will be the behaviour of the threads as far as scheduling is concerned will totally depend upon the underlying OS. when we create a thread e.g. Thread t = new Thread(); then a thread object is created. now when we write t.start(); the thread is added to the pool of ready threads i.e. those threads from where the os scheduler chooses the thread to run. so once we say t.start() our job is over now and how our threads will be running depends upon the particular O.S. only.
that's my understanding. let's see what others think about it. regards deekasha
Tanveer Rameez
Ranch Hand
Joined: Dec 11, 2000
Posts: 158
posted
0
hi, How the order in which threads are executed is based on how the underlying OS implements time-slicing,scheduling. infact in the same machine (under same OS), the order may change at two different times. In cooperative multi-tasking, once a thread takes over the CPU, the other waiting thread gets the chance only if the waiting thread is of higher priority or the running thread gives the CPU voluntarily. So a low priority thread may have to wait a long time, if a higher priority thread has the CPU. IN a pre-emptive time slicing OS like win 98/NT, the low priority thread does not have to starve because of the round robin scheduling that the OS uses. However if we can't predict what will be the os on which the java application will be running, so its better to use Thread.sleep(millis), so that even if a high priority thread is running, it will go to sleep after some time, allowing the other low priority thread to get the CPU atleat for the 'millis' amount of time(milliseconds).
Author of JPhotoBrush Pro (www.jphotobrushpro.com)
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: whose responsible for scheduling Threads ???