Submit the assignment to
with subject “
a program for a clock applet ?
Write a Java program
is a program argument. These
threads access a shared counter (initialized as 0) in a loop. In each iteration, they read the
counter to a local
(stack) variable, increment it, and store it back to the counter.
threads complete 10000 iterations
, the program stops and prints the value of the
Note that the final value may be smaller than the total number of iterations.
program on 1, 4, 8 and 16 threads and report the results in a textual table in the
In your report, include the run time in miliseconds. You can measure the run time by
before and after the execution. See the
The Java concurrency package,
, is a library that provides
synchronization tools for Java programs. This library includes a built
in mutual exclusion
may also look at the ReentrantLock
You are required to write a Java program
doing the same task as in
the shared counter using
, so no two threads
modify the counter at the same time.
Run the program on 1,
4, 8 and 16 threads and report the results in a textual table in the
In your report, include the run time in miliseconds.
Your search mechanism will take as input a multi
word query and will return a
list of documents where
the given words appear.
Your score for this portion of the assignment will be based on the intelligence of
The easiest solution is to simply return a list of documents where
any of the words appear.
Another approach is to give greater
weight to (by
placing earlier in the result set) documents where more than one of the query
Yet another option is to give greater weight to the documents
where the words specified appear closer to one another.
For example, if you
r "computer science" and document 1 has
at position 1 and
at position 2 while document 2 has
at position 1 and
position 100, document 1 would be given higher weight.
Your program will take as input the directory as befo
re along with a file
containing a set of queries.
Each line of the file will contain a multi
The output of your program will be a text file
that contains the result of
running each query.
are required to:
Use Generics when appropriate.
Use the java.util data structures where appropriate.
Keep in mind that Strings are immutable.
You will use a thread pool or work queue and process up to 10 text files in
parallel. As your program traverses the directory specified by the user, for each txt file found
insert a new job into the queue.
To accomplish this, you will n
eed to implement a work queue and a locking
mechanism for your inverted index data structure.
Your locking mechanism will ensure that only 1 thread may change the inverted
index at a time.
Multiple threads may read data in the