InstanceFactory instanceFactory = new InstanceFactory(); ExecutorService executor = Executors.newSingleThreadExecutor(); try (Instance instance = instanceFactory.create()) { instance.init(); instance.doStuff(); while ((input = reader.readNext()) != null) { executor.execute(new Runnable() { @Override public void run() { instance.put(input); } }); } executor.shutdown(); executor.awaitTermination(1, TimeUnit.MINUTES); }
InstanceFactory instanceFactory = new InstanceFactory(); ExecutorService executor = Executors.newCachedThreadPool(); try (Instance instance = instanceFactory.create()) { instance.init(); instance.doStuff(); while ((input = reader.readNext()) != null) { executor.execute(new Runnable() { @Override public void run() { instance.put(input); } }); } } finally { executor.shutdown(); }
/** * Constructor for the <code>Support</code> object. This will * create a support object with the matcher and filter provided. * This allows the user to override the transformations that * are used to convert types to strings and back again. * * @param filter this is the filter to use with this support * @param matcher this is the matcher used for transformations * @param format this contains all the formatting for the XML */ public Support(Filter filter, Matcher matcher, Format format) { this.defaults = new DetailExtractor(this, FIELD); this.transform = new Transformer(matcher); this.scanners = new ScannerFactory(this); this.details = new DetailExtractor(this); this.labels = new LabelExtractor(format); this.instances = new InstanceFactory(); this.matcher = matcher; this.filter = filter; this.format = format; }
/** * Constructor for the <code>Support</code> object. This will * create a support object with the matcher and filter provided. * This allows the user to override the transformations that * are used to convert types to strings and back again. * * @param filter this is the filter to use with this support * @param matcher this is the matcher used for transformations * @param format this contains all the formatting for the XML */ public Support(Filter filter, Matcher matcher, Format format) { this.defaults = new DetailExtractor(this, FIELD); this.transform = new Transformer(matcher); this.scanners = new ScannerFactory(this); this.details = new DetailExtractor(this); this.labels = new LabelExtractor(format); this.instances = new InstanceFactory(); this.matcher = matcher; this.filter = filter; this.format = format; }
/** * Constructor for the <code>Support</code> object. This will * create a support object with the matcher and filter provided. * This allows the user to override the transformations that * are used to convert types to strings and back again. * * @param filter this is the filter to use with this support * @param matcher this is the matcher used for transformations * @param format this contains all the formatting for the XML */ public Support(Filter filter, Matcher matcher, Format format) { this.defaults = new DetailExtractor(this, FIELD); this.transform = new Transformer(matcher); this.scanners = new ScannerFactory(this); this.details = new DetailExtractor(this); this.labels = new LabelExtractor(format); this.instances = new InstanceFactory(); this.matcher = matcher; this.filter = filter; this.format = format; }