My example as follows:
QuestionA
Mutual Exclusion: One or more than one resource are non-shareable (Only one process can use at a time) , In my example, the reasourceA and reasourceB are non-shareable.
Hold and Wait: A process is holding at least one resource and waiting for resources. In my example, just like the thread A, it hold the resource A and wait the resource B.
No Preemption: A resource cannot be taken from a process unless the process releases the resource. In my example , thread A can not get the resouce which is got by thread B.
Circular Wait: A set of processes are waiting for each other in circular form. In mu example , thread A wait thread B , and thread B wait thread A.
QuestionB
We can destroy one of the four necessary conditions of the "circular waiting condition", such as the use of sequential resource allocation method to allocate system resources, stipulating that processes must request resources in the order of increasing number, and similar resources can be applied for at once. In my example, the process that has obtained resource A can apply for resource B, and the process that has obtained resource B cannot apply for resource A, avoiding deadlock.