Skip to content

Instantly share code, notes, and snippets.

View hasskell's full-sized avatar

Dmitry Lobanovsky hasskell

View GitHub Profile
@hasskell
hasskell / brackets.java
Created January 5, 2017 11:42
Bracket match using stack
package stack;
import java.util.*;
import java.util.Stack;
/**
* Created by hasskell on 04/10/16.
*/
public class Brackets {
@hasskell
hasskell / Counter.java
Created December 21, 2016 19:16
RaceCondition example
package race_condition;
/**
* @author Dmitrijs Lobanovskis
* @since 20/12/2016.
*/
public class Counter {
private int count = 0;
private final static int TIMES = 10000;
@hasskell
hasskell / Bus.java
Created December 20, 2016 11:42
Phaser example
package threads;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Phaser;
/**
* @author Dmitrijs Lobanovskis
* @since 20/12/2016.
*/
@hasskell
hasskell / Exchanger.java
Created December 13, 2016 14:37
Exchanger example
package threads;
import java.util.concurrent.Exchanger;
/**
* @author Dmitrijs Lobanovskis
* @since 13/12/2016.
*/
public class Delivery {
@hasskell
hasskell / CrossCountry.java
Created December 13, 2016 11:59
CyclicBarrier example
package threads;
import java.util.concurrent.CyclicBarrier;
/**
* @author Dmitrijs Lobanovskis
* @since 13/12/2016.
*/
public class CrossCountry {
@hasskell
hasskell / Race.java
Created November 27, 2016 13:09
CountDownLatch example
package countDownLatch;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
/**
* Created by hasskell on 27/11/16.
*/
public class Race {
@hasskell
hasskell / CarWash.java
Created November 26, 2016 16:20
Semaphore example
package semaphore;
import java.util.concurrent.Semaphore;
/**
* Created by hasskell on 26/11/16.
*/
public class CarWash {
private static final int SIZE = 5;