diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/WriterActiveObject.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/WriterActiveObject.java new file mode 100644 index 000000000..8f63b6487 --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/WriterActiveObject.java @@ -0,0 +1,24 @@ +package de.dhbwstuttgart.typeinference.unify; + +import java.io.IOException; +import java.io.Writer; +import java.util.concurrent.ForkJoinPool; + +public class WriterActiveObject { + private Writer writer; + private ForkJoinPool pool = new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); + + public WriterActiveObject(Writer writer){ + this.writer = writer; + } + + public void write(String message){ + pool.execute(()->{ + try { + writer.write(message); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + }); + } +}