All are C# related: 1: Which statement is true? Select the one correct answer. T
ID: 3603973 • Letter: A
Question
All are C# related:
1: Which statement is true? Select the one correct answer. Then, explain your reasoning to justify your choice.
No two threads can concurrently execute synchronized methods on the same object.
Methods declared synchronized should not be recursive, since the object lock will not allow new invocations of the method.
Synchronized methods can only call other synchronized methods directly.
Inside a synchronized method, one can assume that no other threads are currently executing any other methods in the same class.
2: How can the priority of a thread be set? What is the effect(s) of changing a thread’s priority?
3: There are at least four plausible reasons why a thread might be alive but still not be running. What are these reasons? What can be done about a live non-running thread? For example, can such threads be detected?
4: What events can cause a thread to die? Are there ways to guarantee that a thread eventually will die?
Explanation / Answer
a. No two threads can concurrently execute synchronized methods on the same object
This does not prevent one thread from executing a non-synchronized method while another thread executes a sysnchronized on the same object.
During the time a thread owns the lock, it may enter and reenter any region of code associated with the lock. So there nothing wrong with recursive synchoronized calls.
Synchorized method call another synchronized and non sychronized methods directly.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.