Skip to content

Instantly share code, notes, and snippets.

@TanyaGaleyev
Created July 5, 2016 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TanyaGaleyev/7eb3d8093344ca404dc31859402deb5c to your computer and use it in GitHub Desktop.
Save TanyaGaleyev/7eb3d8093344ca404dc31859402deb5c to your computer and use it in GitHub Desktop.
Simple application utilizing reactor to demonstrate 100% CPU load on 32 bit Linux
package org.ivan.experiments.reactor;
import reactor.core.publisher.WorkQueueProcessor;
import reactor.core.subscriber.SubmissionEmitter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.Duration;
public class FullCpu {
public static void main(String[] args) throws IOException {
WorkQueueProcessor<Object> processor = WorkQueueProcessor.share();
processor.buffer(Duration.ofMillis(1000L)).subscribe(o -> {
if (!o.isEmpty()) {
System.out.println("Consumed: " + o);
}
});
SubmissionEmitter<Object> emitter = processor.connectEmitter();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String l;
while (!(l = reader.readLine()).equals("q")) {
emitter.emit(l);
}
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment