Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 1.31 KB

README.md

File metadata and controls

23 lines (18 loc) · 1.31 KB

JSON-Database

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write and for machines to parse and generate. It is less verbose and more readable than XML. The JSON filename extension is .json. The official Internet media type for JSON is application/json.

GSON is a Java serialization/deserialization library to convert Java Objects into JSON and vice versa. Gson was created by Google for internal use and later open sourced.

JCommander is a very small Java framework that makes it trivial to parse command line parameters. You annotate fields with descriptions of your options.

We need synchronization because all our threads will work with the same file. Since we can't write the file in two separate threads simultaneously, we used java.util.concurrent.locks.ReentrantReadWriteLock class, an implementation of the ReadWriteLock interface which provides a pair of read-write lock. It allows multiple readers of the resource but only a single writer. Once a writer locks the resource, it waits until all the readers finish reading and only then starts to write. The readers can freely read the file even though other readers locked it, but if the writer locks the file, no readers can read it.

</>