Skip to content

Instantly share code, notes, and snippets.

View y-fedorov's full-sized avatar
🧑‍💻

Yaroslav Fedorov y-fedorov

🧑‍💻
View GitHub Profile
#include <SoftwareSerial.h>
// Arduino Nano 0 - RX 1 - TX
SoftwareSerial mySerial(0, 1);
void setup() {
Serial.begin(115200);
while (!Serial);
@y-fedorov
y-fedorov / ReentrantLockApp.java
Created November 24, 2021 11:43
ReentrantLock Example code
package appstart.mymodappdemo;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.Condition;
public class ReentrantLockApp {
public static void main(String[] args) {
Store store = new Store();
@y-fedorov
y-fedorov / JavaSemaphoreApp.java
Created November 24, 2021 12:05
Java Semaphore App Example
package appstart.mymodappdemo;
import java.util.concurrent.Semaphore;
public class JavaSemaphoreApp {
public static void main(String[] args) {
Semaphore sem = new Semaphore(1); // how many times we can 'acquire' permission
CommonResource res = new CommonResource();
@y-fedorov
y-fedorov / WaitNotifyForThreads.java
Created November 24, 2021 13:47
Wait Notify For Threads Java Example
package appstart.mymodappdemo;
public class WaitNotifyForThreads {
public static void main(String[] args) {
Store store = new Store();
Producer producer = new Producer(store);
Consumer consumer = new Consumer(store);
new Thread(producer).start();
@y-fedorov
y-fedorov / FillRegionsMapInterviewTask.java
Created March 6, 2022 12:08
FillRegionsMapInterviewTask (related to The Four-Color Theorem)
package com.example.demo;
import java.util.Arrays;
public class FillRegionsMapInterviewTask {
// The Four-Color Theorem
//
// In mathematics, the four color theorem, or the four color map theorem,
// states that no more than four colors are required to color the regions
// of any map so that no two adjacent regions have the same color.