Posts

Showing posts from June, 2021

Spring Boot

  D ifferent options of creating Spring Boot projects with Maven and Eclipse 1.  Spring Initializr  https://start.spring.io 2. STS (Spring Tool Suite) Eclipse Plugin                https://www.eclipse.org/community/eclipse_newsletter/2018/february/springboot.php 3. Manually Create a Maven Spring Boot Project     - Create Maven Project  -  Provide Group id, Artifact Id, and version - Add in the appropriate Spring Boot starters into the pom.xml  <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-devtools</artifactId>     <scope>runtime</scope> </dependency> <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-test</artifactId>     <scope>test</scope> </de

Multi Threading , concurency

 Threadpool Example Worker thread: package com.vasanth.java.concurrent; public class Workerthread implements Runnable { private String message; public Workerthread(String message) { super(); this.message = message; } @Override public void run() { System.out.println(Thread.currentThread().getName()+" : Start -> Message="+message); process(); System.out.println(Thread.currentThread().getName()+": End"); } private void process() { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } } Thread pool: package com.vasanth.java.concurrent; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class TestThreadPool { public static void main(String args[]) { ExecutorService executor = Executors.newFixedThreadPool(5); for(int i=1;i<10;i++) { Workerthread workerthread = new Workerthread(""+i); executor.execute(workert