Skip to content

Instantly share code, notes, and snippets.

View prashant4224's full-sized avatar
🏠
Working From Home

Prashant Jeerankalagi prashant4224

🏠
Working From Home
View GitHub Profile
/*--------- Executor Framework -----------*/
java.util.concurrent.Executors
Executor API de-couples execution of tasks from actual task to be executed via Executors
Executor framework to schedule and execute the submitted tasks and return the result from thread pool.
1. Overhead of thread creation & tear-down
2. For each process creating new thread occupy more memory & waste of resources.
ExecutorService executorService = Executors.newSingleThreadExecutor();
ExecutorService executorService = Executors.newFixedThreadPool();
Transaction Isolation levels:
Voilations:
Dirty Reads - A updates,B reads, A rollbacks
Non-Repeatable Reads - A reads, B Updates, A reads found 2 records for same.
Phantom Reads - A reads with where critaria, B insert new record which falls in that where critaria, A reads records with same.
TRANSACTION_READ_UNCOMMITTED
TRANSACTION_READ_COMMITTED
TRANSACTION_REPEATABLE_READ
/*-----------------Beanfactory vs Application Context
Beanfactory:
Bean instantiating/autowiring
Application Context:
Bean instantiating/autowiring
Automatic BeanPostProcessor registraion
Automatic BeanFactoryPostProcessor registraion
Convenient MessageSource access (i18)
ApplicationEvent publication
/* Singleton class double checking */
public class Technology {
private static final Technology instance;
private Technology() {}
public static synchronized Technology getInstatnce() {
if (instance == null) {
synchronized (Technology.class) {
/* Immutable Class */
public final class Box {
private final String key;
private final String value;
private final HashMap<String, String> hm;
public Box(String key, String value, HashMap<String, String> hm) {
this.key = key;
public class User {
private int id;
private String name;
//setters & getters
@Override
public int hashcode() {
final int prime = 31;
int result = 1;
import org.springframework.beans.factory.annotation.Lookup;
import org.springframework.stereotype.Component;
@Component
public class RequestManager{
private RequestHandler requestHandler;
public void handleRequest(){
@Component
public class RequestManager{
@Autowired
private RequestHandler requestHandler;
public void handleRequest(){
requestHandler.handleRequest();
}
}
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetUser`()
BEGIN
SELECT * FROM USER ORDER BY FIRST_NAME;
END
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetTotalUser`()
BEGIN
DECLARE totalUser INT DEFAULT 0;
SELECT COUNT(*) INTO totalUser FROM USER;
SELECT totalUser;
END