• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Are threads guaranteed to be timesliced?

Im studying for my certification exam and have come across the following review question in my book (ive not given the full question, just the main point).

- Consider 3 threads of the same type, all started in the same main() method. The answer to this specific question is (quoted):

"When the application is run, all 3 threads will execute concurrently, taking time-sliced turns on the CPU."

I got this question wrong as I had read somewhere that not all JVMs implement timeslicing, and not all systems support it either. So, in this case, time-slicing cannot be guaranteed and so I was lead to pick another answer (which said, "none of these cases is guaranteed".).

So the question is - Are threads guaranteed to be time sliced?

Not that I dont trust you, but if tyou could provide proof (a link etc) that would be great.

colr__
0
colr__
Asked:
colr__
  • 2
  • 2
1 Solution
 
objectsCommented:
http://java.sun.com/docs/books/tutorial/essential/threads/priority.html

The chosen thread runs until one of the following conditions is true:

    * A higher-priority thread becomes runnable.
    * The thread yields, or its run method exits.
    * On systems that support time-slicing, the thread's time allotment has expired.
0
 
colr__Author Commented:
Thanks objects, that clearly says to me that some systems dont support time-slicing, which tells me that the answer the book gave to this question is misleading.

Out of interest, would you have come to the same conclusion I did in the question, in that the time-slicing isnt guenteed?

colr__
0
 
objectsCommented:
Hard to say what I would have answered now that you've discussed it :) Probably would would havce depended on how much I had thought about it.
Sounds like a typical trick q they use on those type of tests.
0
 
CEHJCommented:
If it's any consolation, i'd have answered the same way, for the same reason. I guess the problem is that it's how loosely the phrase 'time-sliced' is used
0
 
colr__Author Commented:
Thanks guys, much appreciated.

colr__
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now