1- CountDownLatch
3- Phaser

It allows one or more threads to wait until a set of operations being performed in other threads are completed

C:\Users\sanjsingh>javap java.util.concurrent.CountDownLatch
public class java.util.concurrent.CountDownLatch {
public java.util.concurrent.CountDownLatch(int);
public void await() throws java.lang.InterruptedException;
public boolean await(long, java.util.concurrent.TimeUnit) throws java.lang.InterruptedException;
public void countDown();
public long getCount();
public java.lang.String toString();

Modifier and Type Method and Description
void await()
Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted.

boolean await(long timeout, TimeUnit unit)
Causes the current thread to wait until the latch has counted down…

Transaction simply represents a unit of work ,In such case, if one step fails, the whole transaction fails.

Transaction is a Interface in Hibernate

  • The methods of Transaction interface are as follows:
    * void begin() starts a new transaction.
    * void commit() ends the unit of work unless we are in FlushMode.NEVER.
    * void rollback() forces this transaction to rollback.
    * boolean wasCommited() checks if the transaction is commited successfully.
    * boolean wasRolledBack() checks if the transaction is rolledback successfully.

A transaction is associated with Session and instantiated by calling session.beginTransaction().

Example of Transaction Management in Hibernate

Session session = null;
Transaction tx = null;
try {
session = sessionFactory.openSession();
tx = session.beginTransaction();
(Bussiness Logic)
}catch (Exception ex) {
finally {session.close();}

Transaction associated with Dao layer

SHOW VARIABLES LIKE “secure_file_priv”;
SELECT * FROM bootapplication into outfile ‘/ProgramData/MySQL/MySQL Server 8.0/Uploads/mysql_processes.csv’;


Step 2-

download Lombok jar

Goto lombok jar download location and run command
java -jar lombok-1.16.18.jar

Give Lombok Install Path
click on the “Specify Location” button and locate the eclipse.exe

SSH Key on Windows
$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa

Step 3: Add the SSH Key on GitHub
clip < ~/.ssh/id_rsa.pub

step 4 add ssh key in github/gitlab

Step 1 — Run your Spring boot application
Step 2 -http://localhost:9001/h2-console/
port no- Application port no (9001)
Step 3- JDBC URL ,username and password application.yml or properties file

H2 Console on browser
H2 console


Static convenience methods for JavaBeans: for instantiating beans, checking bean property types, copying bean properties, etc.

Case 1- when you need to copy field value from one object to another object

@Transactional — class level and Method level both We are now ready to use @Transactional annotation either at the class or method level.

if you are using JDBC then it will work on DAO layer, but if you are working on JPA or Spring Data then it works on service layer.
Service layer (Manager) represents your business logic and hence it should be annotated with @Transactional.

Implementation of Transactions
To start using @Transactional annotation in a Spring based application, we need to first enable annotations in our Spring application by adding the needed

<tx:annotation-driven transaction-manager=”txManager”/>
Next is to define the transaction…

Using BufferedReader object to read the input text file.\

Step 1 : Create BufferedReader object to read the input text file.
BufferedReader reader = new BufferedReader(new FileReader(“Pass The File Location Here”));
Step 2 : Create one ArrayList object which will hold all the lines or records of input text file.
ArrayList<String> lines = new ArrayList<String>();
Step 3 : Read all the lines of input text file one by one and add the into ArrayList lines.

Reading all the lines of input file one by one and
String currentLine = br.readLine();
while (currentLine != null){
currentLine = br.readLine();}
Step 4 : Sort the ArrayList lines…

/*find all the permutations of a string*/
public class PrintAllPermutations {
public static void permutation(String name, String blank) {
if (name.length() == 0) {
for (int i = 0; i < name.length(); i++) {
String newBlank = blank + name.charAt(i);
String newRemaining =.name.substring(0, i) + name.substring(i + 1);
permutation(newRemaining, newBlank);
}public static void main(String[] args) {
PrintAllPermutations.permutation(“ABCX”, “”);
}} Op T

public class TotalCountVowelsAndConsonants {
public static String count(String name) {
int length = name.trim().length();
int vowels ,consonants;
char[] ch = name.trim().toCharArray();
int count = 0;
for (char c : ch) {
switch (c){
case ‘a’…

Sanjay Singh

Java||Spring-Boot Micro services Application developer||India ||node js || angular

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store