Question: 1 Homework 3 1 . ( 5 pts ) What events do the following components generate in either Swing or FX: JButton or Button JTextField
Homework
pts What events do the following components generate in either Swing or FX:
JButton or Button
JTextField or TextField
JComboBox or ComboBox
pts What methods does JTable implement which are required by the interfaces implemented by
the JTable class beyond those interfaces implemented by the various parent classes of JTable?
pts Address how the differences among these various layout managers, focusing on their behavior
as their container is resized:
a FlowPane in FX or FlowLayout in Swing
b GridPane in FX or GridLayout in Swing
c AncherPane
d TilePane
e Any other layout of your choice in FX or Swing.
ptsEx The dining philosophers problem was invented by E W Dijkstra, a concurrency
pioneer, to clarify the notions of deadlock and starvation freedom. Imagine five philosophers who spend
their lives just thinking and feasting. They sit around a circular table with five chairs. The table has a big
plate of rice. However, there are only five chopsticks in the original formulation forks available, as
shown in Fig. Each philosopher thinks. When he gets hungry, he sits down and picks up the two
chopsticks that are closest to him. If a philosopher can pick up both chopsticks, he can eat for a while.
After a philosopher finishes eating, he puts down the chopsticks and again starts to think.
a What is wrong with everybody doing the following other than that the philosophers never get up
from the table?
think for a while
get left chopstick
get right chopstick
eat for a while
return left chopstick
return right chopstick
return to
b How can the above be fixed to avoid deadlocks?
c Is your solution starvation free? Literally!
pts What methods must a class implementing the java.util.concurrent.locks.Lock interface
implement? Describe some of the expected characteristics of each of the methods of this interface?
pts Explain what the JVM does when it encounters a synchronized directive. Hint: consider
carefully what is synchronized.
pts What is the difference between Lock Interface and synchronized keyword?
Grading Rubric:
Attribute Meets Does not meet
Problem points
Lists the events associated with each
provided component.
points
Does not list the events associated with
each provided component.
Problem points
Lists the methods JTable implements.
Lists the methods which are required
by the interfaces implemented by the
JTable class beyond those interfaces
implemented by the various parent
classes of JTable.
points
Does not list the methods JTable
implements.
Does not list the methods which are
required by the interfaces implemented
by the JTable class beyond those
interfaces implemented by the various
parent classes of JTable.
Problem points
Addresses the differences among the
various layout managers.
Focuses on their behavior as their
container is resized.
points
Does not address the differences among
the various layout managers.
Does not focus on their behavior as their
container is resized.
Problem points
Explains what is wrong with
points
Does not explain what is wrong with
everybody doing the actions provided.
everybody doing the actions
provided.
Explains how the actions be fixed to
avoid deadlocks.
Explains if the solution provided is
starvation free.
Does not explain how the actions be fixed
to avoid deadlocks.
Does not explain if the solution provided is
starvation free.
Problem points
Explains what methods a class
implementing the
java.util.concurrent.locks.Lock
interface must implement.
Describes some of the expected
characteristics of each of the
methods of this interface.
points
Does not explain what methods a class
implementing the
java.util.concurrent.locks.Lock interface
must implement.
Does not describe some of the expected
characteristics of each of the methods of
this interface.
Problem points
Explains what the JVM does when it
encounters a synchronized directive.
points
Does not explain what the JVM does when
it encounters a synchronized directive.
Problem points
Explains difference between Lock
interface and synchronized keyword.
points
Does not explains difference between
Lock interface and synchronized keyword.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
