程序代写代做代考 Java database 1 Database

1 Database
Database.java
Java Threads
Operating Systems
Lab Class 5 – Model Solutions
1

WriterTask.java

ReaderTask.java
Record.java

Reflections:
5. For the example input in the lab sheet, you might get inconsistent output such as
writer 0: Joe Q Brighton
writer 1: Mary L London
reader 2: Joe L London
reader 1: Mary Q London
reader 0: Mary Q Brighton
This happens because the three write operations for first name, last name and address are not atomic, i.e. we have race conditions.
7. The database could provide read and update functions that update respectively read the whole record; these functions could be implemented as monitor functions, i.e. qualifying them synchronized. However, this would make even the readers mutual exclusive among themselves, which is not necessary to avoid race conditions but negatively affects perfor- mance.