Access over 20 million homework & study documents
search

Java Basic/Advanced Interview questions

Content type

User Generated

Subject

Programming

Type

Exam Practice

Rating

Showing Page:
1/44
Table of Contents

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/44
1 Concurrency
Why do threads block on I/O?
Threads block on I/O (that is enters the waiting state) so that other threads may
execute while the I/O Operation is performed.
What is round-robin algo/Time slicing?
Round-robin (RR) is one of the simplest scheduling algorithms for processes in
an operating system. As the term is generally used, time slices are assigned to
each process in equal portions and in circular order, handling all processes
without priority. It is starvation free algo. In order to schedule processes fairly, a
round-robin scheduler generally employs time-sharing, giving each job a time
slot or quantum
[1]
(its allowance of CPU time), and interrupting the job if it is not
completed by then. The job is resumed next time a time slot is assigned to that
process.
What is Preemptive scheduling
Preemptive scheduling enables the highest priority task execution until waiting
or dead states entered. It also executes, until a higher priority task enters.
What is daemon thread
A daemon thread is a thread, that does not prevent the JVM from exiting when
the program finishes but the thread is still running. An example for a daemon
thread is the garbage collection.
You can use the setDaemon() method to change the Thread daemon properties.
How interrupt works in Java?
An interrupt is an indication to a thread that it should stop what it is doing and
do something else. It's up to the programmer to decide exactly how a thread
responds to an interrupt, but it is very common for the thread to terminate.
How does a thread support its own interruption? This depends on what it's
currently doing. If the thread is frequently invoking methods that throw
InterruptedException, it simply returns from the run method after it catches
that exception.
Many methods that throw InterruptedException, such as sleep, are designed to
cancel their current operation and return immediately when an interrupt is
received.
What if a thread goes a long time without invoking a method that throws
InterruptedException? Then it must periodically invoke Thread.interrupted,
which returns true if an interrupt has been received.
e.g.

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/44

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 44 pages?
Access Now

Unformatted Attachment Preview

Table of Contents 1 Concurrency Why do threads block on I/O? Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed. What is round-robin algo/Time slicing? Round-robin (RR) is one of the simplest scheduling algorithms for processes in an operating system. As the term is generally used, time slices are assigned to each process in equal portions and in circular order, handling all processes without priority. It is starvation free algo. In order to schedule processes fairly, a round-robin scheduler generally employs time-sharing, giving each job a time slot or quantum[1] (its allowance of CPU time), and interrupting the job if it is not completed by then. The job is resumed next time a time slot is assigned to that process. What is Preemptive scheduling Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. It also executes, until a higher priority task enters. What is daemon thread A daemon thread is a thread, that does not prevent the JVM from exiting when the program finishes but the thread is still running. An example for a daemon thread is the garbage collection. You can use the setDaemon() method to change the Thread daemon properties. How interrupt works in Java? An interrupt is an indication to a thread that it should stop what it is doing and do something else. It's up to the programmer to decide exactly how a thread responds to an interrupt, ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really great stuff, couldn't ask for more.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4