For this Project 3 Threads milestone, your project must maintain the functionality from the Project 2 Search assignment using a custom-made conditional read/write lock to create a thread-safe inverted index and a custom-made work queue to manage worker threads.
To do this, you should either create new classes or extend existing classes to support multithreading. DO NOT REMOVE YOUR SINGLE THREADING CODE, as you still need to support single threaded building and searching the index.
<aside>
<img src="/icons/error_gray.svg" alt="/icons/error_gray.svg" width="40px" /> Do NOT use any of the classes in the java.util.concurrent
package and do NOT use the Stream.parallel
method for the multithreaded code.
</aside>
TABLE OF CONTENTS
You must complete the following assignments before beginning to work on this one:
Your main
method must be placed in a class named Driver
and must process the following additional command-line arguments:
-threads [num]
where the flag -threads
indicates your code must initialize a thread-safe inverted index, work queue, and enable multithreaded search. See the “Multithreaded Search” section for details.
The next optional argument [num]
is the number of worker threads to use in a work queue. If the [num]
argument is not provided, not a number, or less than 1
, use 5
as the default number of worker threads.
For all v3.0
releases of this project, only multithread the search process. Do not multithread the build process.
These are in addition to the command-line arguments from the previous Project 2 Search assignment.
The command-line flag/value pairs may be provided in any order or not at all. Do not convert paths to absolute form when processing command-line input!
Output user-friendly error messages in the case of exceptions or invalid input. Under no circumstance should your main()
method output a stack trace to the user!
<aside>
<img src="/icons/warning_gray.svg" alt="/icons/warning_gray.svg" width="40px" /> If the -threads
flag is not provided, then multithreading should not be enabled. A thread-safe inverted index should not be initialized, a work queue should not be initialized, and no worker threads should be created. Your main
method should behave the same as previous projects.
</aside>
If multithreading is enabled, the search process from Project v2.1 Tests must be multithreaded as follows:
main
method exits. See the PrimeFinder homework for how to create this work queue.