GithubHelp home page GithubHelp logo

majafary / multithreading-java-vs-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asatklichov/multithreading-java-vs-nodejs

0.0 1.0 0.0 4.8 MB

Multithreading in Java vs Node.js

JavaScript 6.71% Batchfile 0.10% TypeScript 0.58% Java 92.61%

multithreading-java-vs-nodejs's Introduction

Getting Started

This application is used to test multithreading aspects in Java and Node.js. There are multiple examples, some of them solved in multiple ways in Java and in Node.js and as a result we have a measurement table with respective outputs for comparison in the multithreading-java-vs-nodejs.pdf. Also there is a medium article Multithreading in Java vs Node.JS which describes multithreading in Java and Node.js

Examples

  • Then there are multiple Java-main applications, to test core and enhanced Java concurrency features
  • There are synchronous, asynchronous and asynchronous examples using parallelism examples build onto Java 11 http2 features
  • There is a SpringBoot application, where you can see @Async feature using Java CompletableFuture
  • For Reactive programming there are pub-sub examples and custom server implementation, which is a unique example
  • Finally in node.js app there are multiple synch and async examples

Installation

  • For Spring application just execute: run.bat
  • For Node.js just execute: npm ci
  • Other examples are just via plain java main method

Testing

Java Thread Core API

  • Run main methods under 'concurrency.java.core.api' package to see core Java multithreading API examples e.g. deadlock, or race-condition examples, debug it to deep dive

Java Concurrency API

  • Run main methods under 'concurrency.java.concurrent.api' package to see Java concurrency API examples e.g. different locks, executors, producer-consumers, ..

Java Enhanced Concurrency - CompletableFuture with Java 11 http2 client

  • See concurrency.completablefuture.api package to understand CompletableFuture
  • Run main methods under 'concurrency.completablefuture.java11.httpclient' package to see synchronous, asynchronous and asynchronous examples using parallelism examples build onto Java 11 http2 features

SpringBoot - @Async with CompletableFuture

Java Enhanced Concurrency - Reactive Programming with Flow API, custom http-server

  • Run Java9SubmissionPublisherDemo & Java9FlowableStreamDemo to play with Reactive Programming basics which came with Java 9 Flow API
  • Run AkkaPubSubDemo.java to play with akka reactive library
  • Run RxJavaBackpressureDemo.java to play with rxjava reactive library
  • Bonus: Run custom http-server server: MySimpleHttpServer.java then run either java-client MyHttpClient or request it via browser: http://localhost:8000/serve

Node.js

After you have installed the dependencies, described as above, just run like below examples. Also you can change the parameters or input file accordingly.

  • Sync: multithreading-java-vs-nodejs\nodejs-app\src>node validate-domain-async3.js
  • Async: multithreading-java-vs-nodejs\nodejs-app\src>node validate-domain-sync.js
  • Async Axios: multithreading-java-vs-nodejs\nodejs-app\src>node validate-domain-axios.js
  • Async Got: multithreading-java-vs-nodejs\nodejs-app\src>node validate-domain-got.js
  • Worker: multithreading-java-vs-nodejs\nodejs-app\src>node worker-parent.js

multithreading-java-vs-nodejs's People

Watchers

James Cloos avatar

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.