Deadlock is a state where one thread waits for another thread to release a resource and the another thread also waits for some resources. This leads to a situation where the threads will wait for infinite time. This scenario can be created using java code where an object can be treated a common resource. Example of deadlock in java: public class SharedResource { synchronized void method1(SharedResource sr) { System.out.println("Method 1"); sr.method2(this); } synchronized void method2(SharedResource sr) { System.out.println("Method 2"); sr.method1(this); } } public class TestMain { public static void main(String[] args) throws InterruptedException { SharedResource sc1 = new SharedResource(); SharedResource sc2 = new SharedResource(); Thread t1 = new Thread(() -> { sc1.method1(sc2); }); Thread t2 = new Thread(() -> { sc2.method2(sc1); }); t1.start(); t2.start(); t1.join(); t2.join(); } } As y...
When we start a new java based web application, spring boot comes as one of the best choices to start the backend development. As it is easy to develop, test and maintain. These are the four ways to create a spring boot application Spring Boot CLI Using STS (IDE) Convert Maven / Gradle Application to Spring Boot Using Spring Starter Web Prerequisite for all the four ways are Java 8 or above and Maven/Gradle. Let us understand each options in detail Spring Boot CLI Spring Boot CLI provides a command line interface to create spring boot application. Users need to install a CLI tool to execute the commands. This is least preferred way as we have better options available on spring starter and in the IDE. Using STS (IDE) STS (Spring Tool Suite) comes with spring starter integrated with it. We can choose few options and the tool will generate a basic spring boot structure. Follow the steps to create Spring Boot application using STS Install and Open STS in your desktop...