Skip to content

Instantly share code, notes, and snippets.

View FuncGuy's full-sized avatar
🥇

Tirumalesh FuncGuy

🥇
  • Bangalore
  • 07:48 (UTC -12:00)
View GitHub Profile
@FuncGuy
FuncGuy / ConsumerTask.java
Created February 21, 2020 02:36 — forked from VarunVats9/ConsumerTask.java
Count Min Sketch
import java.util.concurrent.BlockingQueue;
public class ConsumerTask implements Runnable {
private static final int H1 = 0;
private static final int H2 = 1;
private static final int H3 = 2;
private static final int H4 = 3;
final static int LIMIT = 100;
@FuncGuy
FuncGuy / EvenOdd.java
Created February 3, 2020 14:26
Print Even Odd number using multiple threads.
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class EvenOdd {
private boolean iseven;
private Lock lock = new ReentrantLock();
package vendingMachine;
import java.util.Map;
import java.util.Set;
public class VendingMachine {
private int collectedCash;
private State state;
private Map<String, Set<String>> productCodeItemMap;
private Map<String, Integer> productCodePriceMap;
@FuncGuy
FuncGuy / ScalingThreadPoolExecutor.java
Created November 18, 2019 07:55 — forked from mnadeem/ScalingThreadPoolExecutor.java
Scalable Thread Pool Executor (TPE) Which first creates threads up to max pool size and then queue up the tasks (Queue Does not depends upon Executor)
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TransferQueue;
public final class ScalingThreadPoolExecutor extends ThreadPoolExecutor {
@FuncGuy
FuncGuy / GoConcurrency.md
Created October 6, 2019 08:34 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines