Skip to content

Instantly share code, notes, and snippets.

@JavaNoobPig
JavaNoobPig / Multithreading_33.java
Created September 30, 2021 13:28
Multithreading_33
package com.pig20;
public class Main {
public static void main(String[] args) throws InterruptedException {
InventoryCounter inventoryCounter =new InventoryCounter();
IncrementingThread incrementingThread=new IncrementingThread(inventoryCounter);
DecrementingThread decrementingThread=new DecrementingThread(inventoryCounter);
incrementingThread.start();
@JavaNoobPig
JavaNoobPig / Multithreading_32.java
Created September 28, 2021 13:48
Multithreading_32
public class SimpleCountDownLatch {
private int count;
public SimpleCountDownLatch(int count) {
this.count = count;
if (count < 0) {
throw new IllegalArgumentException("count cannot be negative");
}
}
@JavaNoobPig
JavaNoobPig / Multithreading_31.java
Created September 28, 2021 13:47
Multithreading_31
package com.pig19;
//這是編碼練習的自己的解答
public class SimpleCountDownLatch_solu {
private int count;
public SimpleCountDownLatch_solu(int count) {
this.count = count;
if (count < 0) {
throw new IllegalArgumentException("count cannot be negative");
@JavaNoobPig
JavaNoobPig / Multithreading_30.java
Created September 28, 2021 13:46
Multithreading_30
package com.pig19;
//這是編碼練習的題目
public class SimpleCountDownLatch {
private int count;
public SimpleCountDownLatch(int count) {
this.count = count;
if (count < 0) {
throw new IllegalArgumentException("count cannot be negative");
}
@JavaNoobPig
JavaNoobPig / Multithreading_29.java
Created September 27, 2021 15:49
Multithreading_29
/*
* MIT License
*
* Copyright (c) 2019 Michael Pogrebinsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@JavaNoobPig
JavaNoobPig / Multithreading_28.java
Created September 27, 2021 15:29
Multithreading_28
/*
* MIT License
*
* Copyright (c) 2019 Michael Pogrebinsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@JavaNoobPig
JavaNoobPig / Multithreading_27.java
Created September 27, 2021 14:28
Multithreading_27
package com.pig18;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;
import java.util.StringJoiner;
/**
* Objects as Condition Variables - Wait(), Notify() and NotifyAll()
@JavaNoobPig
JavaNoobPig / Multithreading_26.java
Created September 23, 2021 13:04
Multithreading_26
package com.pig18;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class Main {
@JavaNoobPig
JavaNoobPig / Multithreading_25.java
Created September 17, 2021 13:01
Multithreading_25
package com.pig17;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Reentrant Read Write Lock & Database Implementation
* https://www.udemy.com/java-multithreading-concurrency-performance-optimization
@JavaNoobPig
JavaNoobPig / Multithreading_24.java
Created September 17, 2021 12:56
Multithreading_24
package com.pig17;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Reentrant Read Write Lock & Database Implementation
* https://www.udemy.com/java-multithreading-concurrency-performance-optimization