This file contains 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
import java.util.concurrent.{Executors, TimeUnit} | |
import rx.lang.scala.Observable | |
import scala.concurrent.duration._ | |
//import scala.concurrent.ExecutionContext.Implicits.global | |
import rx.lang.scala.schedulers.{ComputationScheduler, ExecutionContextScheduler} | |
import scala.concurrent.{ExecutionContext, Future} |
This file contains 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
import java.util.concurrent.{Executors, TimeUnit} | |
import rx.lang.scala.Observable | |
import scala.concurrent.duration._ | |
//import scala.concurrent.ExecutionContext.Implicits.global | |
import rx.lang.scala.schedulers.{ComputationScheduler, ExecutionContextScheduler} | |
import scala.concurrent.{ExecutionContext, Future} |
This file contains 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 com.example.demo; | |
import java.util.concurrent.Semaphore; | |
public class SemaphoreExample { | |
private static final Semaphore PARKING = new Semaphore(3); | |
public static void main(String[] args) throws InterruptedException { | |
for (int i = 1; i <= 9; i++) { |
This file contains 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 com.example.demo; | |
import java.util.concurrent.BrokenBarrierException; | |
import java.util.concurrent.CyclicBarrier; | |
public class CyclingBarrierExample { | |
private static final CyclicBarrier BARRIER = new CyclicBarrier(3, new FerryBoat()); | |
public static void main(String[] args) throws InterruptedException { |
This file contains 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 com.example.demo; | |
import java.util.concurrent.CountDownLatch; | |
public class CountDownLatchExample { | |
private static final CountDownLatch START = new CountDownLatch(5); | |
public static void main(String[] args) throws InterruptedException { | |
System.out.println("Waiting 5 cars appearing to the start line"); |
This file contains 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 popatsap.blog.kafkaexample; | |
import org.apache.kafka.clients.consumer.ConsumerRecord; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.CommandLineRunner; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.context.ConfigurableApplicationContext; |
This file contains 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
//id to detect which object was chosen to remain | |
case class TC(id: Long, value: String) { | |
override def equals(obj: Any): Boolean = obj match { | |
case tc: TC => value == tc.value | |
case _ => false | |
} | |
} |