Giter VIP home page Giter VIP logo

multi_threaded_ms's Introduction

Name: MULTI THREADED MERGE SORT



Following are the commands and the instructions to run ANT.

Note: build.xml is present in multiThreadedMS/src folder.


Instruction to clean:

####Command: ant -buildfile multiThreadedMS/src/build.xml clean

Description: It cleans up all the .class files that were generated when you compiled your code.


Instruction to compile:

####Command: ant -buildfile multiThreadedMS/src/build.xml all

Description: Compiles your code and generates .class files inside the BUILD folder.


Instruction to run:

####Command: ant -buildfile multiThreadedMS/src/build.xml run -Dargs='3 input1.txt input2.txt input3.txt output.txt 3'

Example:

The last argument is the Logger value. ant -buildfile multiThreadedMS/src/build.xml run -Dargs='3 input1.txt input2.txt input3.txt output.txt 3'

set the debugger value to 3 in order to check whether all threads ran. The output for which should be something like this, Thread 12 is alive: false The output basically contains the thread id and shows whether the thread is alive or not. If the thread is not alive means the program has completed successfully and the thread has done it job, but if the thread is still alive after join method means the thread was still running and there might be some error due to which the thread was still alive and couldn't complete it's task.


Description:

The code perfroms the following tasks:

Reads the command line arguments. Creates an instance of Results. Creates N threaded Objects (instances of ThreadWorker class) where in we pass the reference to Results in the constructor of each ThreadedWorker. Starts the N threaded Objects. Calls an instance of the class in util/ package that does merge sort, and pass it an instance of Results so it can access the data that was written by all the threads. After the Merge sort is completed, we call a method in Results, via the method in FileDisplayInterface, to write the data stored in Results to output.txt,which would be in non-descreasing order if merge sort succeeded.

I have used array list as my data structure to store the values that will be read by each thread from the input text file and also to store the sorted values of each thread in result.java I had used arraylist. In order to synchronize the threads I had called synchronize method on result object which will be passed to the threadworker constructor by every thread that will be created. I have passed the same instance of result across all the threads and had also made use of join method to ensure that a thread waits for the other thread until that thread completes it's execution.


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.