class SynchronousProducerConsumerProcessor {

    public void execute()
    {
        final Instant endProcessingTime = Instant.now().plusSeconds(runMaxSeconds);

        itemsProcessedCount = 0;
        producer.reset();
        while(true)
        {
            ProducerResult<T> producerResult = producer.produce(endProcessingTime);
            if(producerResult.isInterrupted()
                || producerResult.getItemsProduced() == null
                || producerResult.getItemsProduced().size() == 0
                || InstantUtil.isNowAfterOrEqual(endProcessingTime))
            {
                break;
            }

            ConsumerResult<T> consumerResult = consumer.consume(producerResult.getItemsProduced(), endProcessingTime);

            itemsProcessedCount += consumerResult.getItemsConsumedCount();

            if(consumerResult.isInterrupted())
            {
                break;
            }
        }

        if(InstantUtil.isNowAfterOrEqual(endProcessingTime))
        {
            processingTimeExpired();
        }
    }

    public  SynchronousProducerConsumerProcessor(Producer<T> producer, Consumer<T> consumer);

}