C call the component classs repaint method however

This preview shows page 2 out of 3 pages.

c. Call the Component class’s repaint method. However, creating containers with absolutely positioned containers can cause problems if the window containing the container is resized. 4. If the philosophers pick up a chopstick to their left (or right) at the same time, deadlock will occur. Only two philosophers at the same time can eat, which results in three starving. b . To avoid deadlocks, consider each chopstick as a shared item protected by a mutex lock. Before each philosopher can eat, he must lock his left chopstick and then lock his right chopstick. If the acquisitions of both locks are successful, the philosopher owns two chopsticks (or two locks), and can now eat. After finished eating, the philosopher releases both chopsticks, and then thinks. Each chopstick is associated with a mutex lock because it needs to lock and unlock. c . Yes. The best way to approach this is to have no philosopher wait more than a specified amount of time for both chopsticks, and that any adjacent philosopher does not acquire the chopstick before him. If any of the philosopher is hungry, he must wait first. 5. A java.util.concurrent.locks.Lock is a thread synchronization mechanism like synchronized blocks. A Lock is, however, more flexible and more sophisticated than a synchronized block. Some of the methods of the Lock interface are: a. lock() – locks the Lock instance if possible. If the Lock instance is already locked, the thread calling lock() is blocked until the Lock is unlocked.
Image of page 2
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern