This file contains hidden or 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
| 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(); |
This file contains hidden or 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
| package org.redquark.kickstarter.threads; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.Random; | |
| import java.util.concurrent.*; | |
| public class CallableFutureImplementation { |
This file contains hidden or 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
| 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, |
This file contains hidden or 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
| 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) { |
This file contains hidden or 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
| 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)); |
This file contains hidden or 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
| 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); |
This file contains hidden or 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
| 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) { |
This file contains hidden or 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
| 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++) { |
This file contains hidden or 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
| 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); |
This file contains hidden or 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
| 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); |