title: "Postgres Database Migration" date: 2020-04-17T21:00:46+05:30 draft: true metaAlignment: center categories: [] tags: []
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class BlockingQueue<T> { | |
private Queue<T> queue = new LinkedList<T>(); | |
private int capacity = 10; //default capacity is 10 | |
BlockingQueue() {} | |
BlockingQueue(int capacity) { | |
this.capacity = capacity; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//we are using our own definition of BlockingQueue as created by us in BlockingQueue.java file | |
public class ThreadPool { | |
private BlockingQueue<Runnable> taskQueue = null; | |
private List<PoolThread> threads = new ArrayList<PoolThread>(); | |
private boolean isStopped = false; | |
public ThreadPool(int noOfThreads, int maxNoOfTasks) { | |
taskQueue = new BlockingQueue<Runnable>(maxNoOfTasks); | |
for(int i=0; i<noOfThreads; i++) { | |
threads.add(new PoolThread(taskQueue)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* in ReadWriteLock notifyAll() is called rather than notify() | |
* inside this lock many threads are waiting for read access and threads waiting for write access. if a thread is awakened by notify() was a read access thread, it would be put back to waiting because there are threads waiting for write access. | |
* however none of the threads awaiting write access are awakened, so nothing more happens. no threads gain neither read nor write access. | |
*/ | |
class ReadWriteLock { | |
private int readers = 0; | |
private int writers = 0; | |
private int writeRequests = 0; |
VCS - Version Control System tracks the history of changes on a project
DVCS - Distributed VCS. Git is also a DVCS. Git doesn't need a constant connection to a central repository. Developers can work anywhere and colloborate asynchronously from any time zone.
Repository - repo or git project. It encompasses the entire collection of files and folders associated with the project, along with each file's revision history. This revision history appears as snapshots called commits, and the commits exist as a linked list relationship and can be organized into multiple lines of development called branches
git init
- initializes a brand new git repo. It adds a hidden subfolder that houses the internal data structures required for version control