After a thread gets access to the CPU and executes some instructions in its run method, the thread can lose access to the CPU in several ways. Describe three ways, and how the threads are resumed. What is context switching?

What will be an ideal response?


* Time-out: Most computers running Java programs automatically time out a running thread every few milliseconds. The process of automatically timing out, called time slicing, pauses the running thread's execution and sends it to the rear of the ready queue. The thread at the front of the ready queue is given access to the CPU.

* Sleep: A thread can be put to sleep for a given number of milliseconds. When the thread wakes up, it goes to the rear of the ready queue.

*Block: A thread can wait for some event, such as user input, to occur. When a blocked thread is notified that an event has occurred, it goes to the rear of the ready queue.

* Wait: A thread can voluntarily relinquish the CPU to wait for some condition to become true. A waiting thread can be notified when the condition becomes true, and move again to the rear of the ready queue.

Context switching is the process of saving and restoring a thread's state so that when the thread returns to the CPU, its run method can pick up where it left off.

Computer Science & Information Technology

You might also like to view...

Classes can be created from other classes by using _______________

a) encapsulation b) polymorphism c) inheritance d) attributes e) machine code

Computer Science & Information Technology

What type of information can be gathered from encrypted network traffic?

A. Private encryption keys B. Information transmitted during an SSL session C. The sender’s IP address, receiver’s IP address, the DNS request to resolve the host name and the port numbers used D. No information can be gathered

Computer Science & Information Technology

Calling a member function of an object requires which item?

a. The dot operator. b. Open and close braces. c. The class name. d. None of the above.

Computer Science & Information Technology

For which of the following would polymorphism not provide a clean solution?

a) A billing program where there is a variety of clients who are billed with different fee structures. b) A maintenance log program where a variety of machine data is collected and maintenance schedules are produced for each machine based on the data collected. c) A program to compute a 5% savings account interest for bank clients. d) An IRS program that maintains information on a variety of taxpayers and determines who to

Computer Science & Information Technology