Skip to content

Instantly share code, notes, and snippets.

View ani03sha's full-sized avatar
👨‍💻
Web 2.0 --> Web 3.0

Anirudh Sharma ani03sha

👨‍💻
Web 2.0 --> Web 3.0
View GitHub Profile
package org.redquark.kickstarter.threads;
public class DeadlockImplementation {
public static void main(String[] args) {
DeadlockImplementation deadlockImplementation = new DeadlockImplementation();
final A a = deadlockImplementation.new A();
final B b = deadlockImplementation.new B();
package org.redquark.kickstarter.threads;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.*;
public class CallableFutureImplementation {
package org.redquark.kickstarter.threads;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
public class CyclicBarrierImplementation {
public static void main(String[] args) {
final CyclicBarrier cyclicBarrier = new CyclicBarrier(3,
package org.redquark.kickstarter.threads;
import java.util.concurrent.locks.ReentrantLock;
public class ReentrantLockImplementation {
private static ReentrantLock reentrantLock = new ReentrantLock();
private static int count = 0;
public static void main(String[] args) {
package org.redquark.kickstarter.threads;
import java.util.concurrent.CountDownLatch;
public class CountDownLatchImplementation {
public static void main(String[] args) {
final CountDownLatch latch = new CountDownLatch(3);
Thread loginService = new Thread(new Service("Login Service", 1000, latch));
package org.redquark.kickstarter.threads;
import java.util.concurrent.Semaphore;
public class SemaphoreImplementation {
public static void main(String[] args) throws InterruptedException {
// Initializing semaphore object
Semaphore semaphore = new Semaphore(1);
package org.redquark.kickstarter.threads;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ThreadPoolExecutorImplementation {
public static void main(String[] args) {
package org.redquark.kickstarter.threads;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ThreadPoolImplementation {
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(3);
for (int i = 0; i < 5; i++) {
package org.redquark.kickstarter.threads;
public class _13SynchronizationImplementation {
public static void main(String[] args) {
Sender sender = new Sender();
SendThread s1 = new SendThread("Hello World!", sender);
SendThread s2 = new SendThread("Bye World!", sender);
Thread t1 = new Thread(s1);
package org.redquark.kickstarter.threads;
public class Join {
public static void main(String[] args) {
JoinDemo demo = new JoinDemo();
Thread t1 = new Thread(demo);
Thread t2 = new Thread(demo);
Thread t3 = new Thread(demo);