Problem 2
State whether each of the following is true or false. If false, explain why.
a)
Problem 3
State whether each of the following is true or false. If false, explain why. a) Method sleep does not consume processor time while a thread sleeps. b) Declaring a method synchronized guarantees that deadlock cannot occur. c) Once a Lock has been obtained by a thread, the Lock object will not allow another thread to obtain the lock until the first thread releases it. d) Swing components are thread safe.
Problem 4
Define each of the following terms. a) thread b) multithreading c) runnable state d) timed waiting state e) preemptive scheduling f) Runnable interface g) notifyAl 7 method h) producer/consumer relationship i) quantum
Problem 5
Discuss each of the following terms in the context of Java's threading mechanisms: a) synchronized b) producer c) consumer d) wait e) notify f) Lock g) Condition
Problem 7
Two problems that can occur in systems that allow threads to wait are deadlock, in which one or more threads will wait forever for an event that cannot occur, and indefinite postponement, in which one or more threads will be delayed for some unpredictably long time. Give an example of how each of these problems can occur in multithreaded Java programs.
Problem 8
Write a program that bounces a blue ball inside a JPane7. The ball should begin moving with a mousePressed event. When the ball hits the edge of the JPane 7 , it should bounce off the edge and continue in the opposite direction. The ball should be updated using a Runnable.