@Test public void raceConditionsWhenPublishing() throws InterruptedException { Producer slow = new SlowProducer(new Jedis("localhost"), "foo"); Consumer c = new Consumer(new Jedis("localhost"), "a subscriber", "foo"); slow.publish("a"); Thread t = new Thread(new Runnable() { @Override public void run() { Producer fast = new Producer(new Jedis("localhost"), "foo"); fast.publish("b"); } }); t.start(); t.join(); assertEquals("a", c.consume()); assertEquals("b", c.consume()); }
public void publish(final String message) { publish(message, 0); }
Producer { public void publish(final String message) { publish(message, 0); } }
Producer { public void publish(final String message) { publish(message, 0); } Producer(final Jedis jedis, final String topic); }
Producer { public void publish(final String message) { publish(message, 0); } Producer(final Jedis jedis, final String topic); void publish(final String message); void clean(); void publish(String message, int seconds); }
Producer { public void publish(final String message) { publish(message, 0); } Producer(final Jedis jedis, final String topic); void publish(final String message); void clean(); void publish(String message, int seconds);  }