A small java-application to manifest the beauty of multi-threaded programs. It simply reads different cricketers' profile from CricBuzz.com, and display some stats. Code entirely written in core-java.
- Download apache-commons library first from this maven-repository, page link https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.8.1
- Add this jar file in your build-path in eclipse/IntelliJ. We are going to use one API from the StringUtils class.
- Run the SingleThreadedStats class as a java-app, currently it processes 150 cricketers' profiles.
- Run the MultiThreadedStats class next as a java-app, it processes 10000 cricketers' profiles.
- See the difference in execution-time, you will understand why multi-threading is preferred in this kind of scenario.
- Play with the app, and see where it breaks.
- A small update, the project has been converted to a maven-project and the apache-common library is added as a maven dependency. So you don't need to set the classpath. You can import the project as a maven-project, build the project, and start using it.
- Get Maven (https://maven.apache.org/), set it up in your classpath
- Clone the project, go to its base-directory. If downloaded, unzip the file and go to its base.
- Open CMD, run mvn clean install
- Copy the big jar containing dependencies (fileName: CricketStats-1.0.0-jar-with-dependencies.jar) into a suitable folder
- Go to that folder and execute the following command $java -jar CricketStats-1.0.0-jar-with-dependencies.jar
- As of May-2019, the stats-data have been moved from printing in the console to write to external files because of buffer-constraint. Now run the Multi-threaded program to see the stats-data become available in different cricbuzz__stats text files in the root folder.
Your valuable comments are most welcome, write me back at jmandal82 AT hotmail.com