Test
This commit is contained in:
1 parent
1e899d7e62
commit
5be14364fd
5 files changed
+40
-277
No files matched your search
@@ -6,8 +6,8 @@
|
||||
package bandit.Model;
|
||||
|
||||
import bandit.Model.Generator.Generator1;
|
||||
import bandit.Model.Generator.Generator2;
|
||||
import bandit.Model.Generator.Generator3;
|
||||
//import bandit.Model.Generator.Generator2;
|
||||
//import bandit.Model.Generator.Generator3;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Flow.Subscriber;
|
||||
@@ -21,34 +21,34 @@ import java.util.concurrent.Flow;
|
||||
*
|
||||
* @author le
|
||||
*/
|
||||
public class Zahlengenerator implements Subscriber<Integer[]> // Callable
|
||||
public class Zahlengenerator implements Subscriber<Integer> // Callable
|
||||
{
|
||||
private static Logger lg = OhmLogger.getLogger(); //Logger sollten immer static sein da sie für alle instanzen loggs ausführen
|
||||
|
||||
private Flow.Subscription subscription;
|
||||
private SubmissionPublisher<Integer[]> wertPublisher;
|
||||
private SubmissionPublisher<Integer> wertPublisher;
|
||||
|
||||
private Generator1 generator1;
|
||||
private Thread thd1;
|
||||
|
||||
private Generator2 generator2;
|
||||
private Thread thd2;
|
||||
|
||||
private Generator3 generator3;
|
||||
private Thread thd3;
|
||||
|
||||
// private Generator2 generator2;
|
||||
// private Thread thd2;
|
||||
//
|
||||
// private Generator3 generator3;
|
||||
// private Thread thd3;
|
||||
//
|
||||
|
||||
public Zahlengenerator()
|
||||
{
|
||||
wertPublisher = new SubmissionPublisher<>();
|
||||
generator1 = new Generator1(this);
|
||||
generator2 = new Generator2(this);
|
||||
generator3 = new Generator3(this);
|
||||
// generator2 = new Generator2(this);
|
||||
// generator3 = new Generator3(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addWertSubscription(Subscriber<Integer[]> subscriber)
|
||||
public void addWertSubscription(Subscriber<Integer> subscriber)
|
||||
{
|
||||
wertPublisher.subscribe(subscriber);
|
||||
}
|
||||
@@ -57,20 +57,22 @@ public class Zahlengenerator implements Subscriber<Integer[]> // Callable
|
||||
{
|
||||
if(thd1==null){
|
||||
thd1 = new Thread(generator1);
|
||||
lg.info("thd1.start");
|
||||
thd1.start();
|
||||
}
|
||||
if(thd2==null){
|
||||
thd2 = new Thread(generator2);
|
||||
thd2.start();
|
||||
}
|
||||
if(thd3==null){
|
||||
thd3 = new Thread(generator3);
|
||||
thd3.start();
|
||||
}
|
||||
// if(thd2==null){
|
||||
// thd2 = new Thread(generator2);
|
||||
// thd2.start();
|
||||
// }
|
||||
// if(thd3==null){
|
||||
// thd3 = new Thread(generator3);
|
||||
// thd3.start();
|
||||
// }
|
||||
|
||||
lg.info("generator1.start");
|
||||
generator1.start();
|
||||
generator2.start();
|
||||
generator3.start();
|
||||
//generator2.start();
|
||||
//generator3.start();
|
||||
|
||||
|
||||
}
|
||||
@@ -78,8 +80,8 @@ public class Zahlengenerator implements Subscriber<Integer[]> // Callable
|
||||
public void stop()
|
||||
{
|
||||
generator1.stop();
|
||||
generator2.stop();
|
||||
generator3.stop();
|
||||
//generator2.stop();
|
||||
//generator3.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +95,7 @@ public void onSubscribe(Flow.Subscription subscription) {
|
||||
|
||||
|
||||
@Override
|
||||
public void onNext(Integer[] item) {
|
||||
public void onNext(Integer item) {
|
||||
this.wertPublisher.submit(item);
|
||||
this.subscription.request(1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user