List of usage examples for java.util.concurrent Executors newSingleThreadScheduledExecutor
public static ScheduledExecutorService newSingleThreadScheduledExecutor()
From source file:org.libreoffice.impressremote.communication.TcpServersFinder.java
@Override public void startSearch() { stopSearch();/*from w ww . ja v a 2 s .c o m*/ mSearchService = Executors.newSingleThreadScheduledExecutor(); mSearchService.scheduleAtFixedRate(this, 0, SEARCH_DELAY_IN_SECONDS, TimeUnit.SECONDS); }
From source file:org.dcm4che.tool.mppsscu.MppsSCU.java
@SuppressWarnings("unchecked") public static void main(String[] args) { try {//from ww w . j a v a2s. com CommandLine cl = parseComandLine(args); Device device = new Device("mppsscu"); Connection conn = new Connection(); device.addConnection(conn); ApplicationEntity ae = new ApplicationEntity("MPPSSCU"); device.addApplicationEntity(ae); ae.addConnection(conn); final MppsSCU main = new MppsSCU(ae); configureMPPS(main, cl); CLIUtils.configureConnect(main.remote, main.rq, cl); CLIUtils.configureBind(conn, main.ae, cl); CLIUtils.configure(conn, cl); main.remote.setTlsProtocols(conn.getTlsProtocols()); main.remote.setTlsCipherSuites(conn.getTlsCipherSuites()); main.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); main.setAttributes(new Attributes()); CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s")); main.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) { System.out.println(rb.getString("scanning")); DicomFiles.scan(argList, new DicomFiles.Callback() { @Override public boolean dicomFile(File f, Attributes fmi, long dsPos, Attributes ds) { if (UID.ModalityPerformedProcedureStepSOPClass .equals(fmi.getString(Tag.MediaStorageSOPClassUID))) { return main.addMPPS(fmi.getString(Tag.MediaStorageSOPInstanceUID), ds); } return main.addInstance(ds); } }); } ExecutorService executorService = Executors.newSingleThreadExecutor(); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); device.setExecutor(executorService); device.setScheduledExecutor(scheduledExecutorService); try { main.open(); if (echo) main.echo(); else { main.createMpps(); main.updateMpps(); } } finally { main.close(); executorService.shutdown(); scheduledExecutorService.shutdown(); } } catch (ParseException e) { System.err.println("mppsscu: " + e.getMessage()); System.err.println(rb.getString("try")); System.exit(2); } catch (Exception e) { System.err.println("mppsscu: " + e.getMessage()); e.printStackTrace(); System.exit(2); } }
From source file:com.ms.commons.fasttext.FasttextService.java
private static void createThreadPool() { Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() { public void run() { reload();/*from ww w . j a va 2s .co m*/ } }, DELAY_TIME, DELAY_TIME, TimeUnit.SECONDS); }
From source file:com.linkedin.kmf.services.StatsdMetricsReporterService.java
public StatsdMetricsReporterService(Map<String, Object> props, String name) { StatsdMetricsReporterServiceConfig config = new StatsdMetricsReporterServiceConfig(props); _name = name;//from w w w.ja va 2 s. c o m _metricNames = config.getList(StatsdMetricsReporterServiceConfig.REPORT_METRICS_CONFIG); _reportIntervalSec = config.getInt(StatsdMetricsReporterServiceConfig.REPORT_INTERVAL_SEC_CONFIG); _executor = Executors.newSingleThreadScheduledExecutor(); _statsdClient = new NonBlockingStatsDClient( config.getString(StatsdMetricsReporterServiceConfig.REPORT_STATSD_PREFIX), config.getString(StatsdMetricsReporterServiceConfig.REPORT_STATSD_HOST), config.getInt(StatsdMetricsReporterServiceConfig.REPORT_STATSD_PORT)); }
From source file:org.pdfsam.guiclient.business.listeners.mediators.UpdateCheckerMediator.java
public UpdateCheckerMediator(JStatusPanel statusPanel) { this.statusPanel = statusPanel; this.executor = Executors.newSingleThreadScheduledExecutor(); }
From source file:com.taobao.tddl.jdbc.atom.config.DiamondDbConfManager.java
public void init() { configFactory = new DefaultConfigDataHandlerFactory(); Map<String, String> config = new HashMap<String, String>(); config.put("group", TAtomConstants.DEFAULT_DIAMOND_GROUP); globalHandler = configFactory.getConfigDataHandlerWithListenerListCE(globalConfigDataId, globalDbConfListener, Executors.newSingleThreadScheduledExecutor(), config); appDBHandler = configFactory.getConfigDataHandlerWithListenerListCE(appConfigDataId, appDbConfListener, Executors.newSingleThreadScheduledExecutor(), config); }
From source file:org.impalaframework.spring.config.BaseDynamicPropertySource.java
public void afterPropertiesSet() throws Exception { run();//from w w w. j ava 2 s. co m //if we don't already have an executor service, create a single threaded executor if (executorService == null) { logger.info("No executor service wired in for '" + this.getClass().getName() + "'. Creating new single threaded executor"); executorService = Executors.newSingleThreadScheduledExecutor(); } logger.info("Starting executor service for for '" + this.getClass().getName() + "'. Initial delay: " + reloadInitialDelay + " seconds, interval: " + reloadInterval + " seconds"); executorService.scheduleWithFixedDelay(this, reloadInitialDelay, reloadInterval, TimeUnit.SECONDS); }
From source file:com.kurtraschke.wsf.gtfsrealtime.WSFRealtimeModule.java
@Override protected void configure() { bind(HttpClientConnectionManager.class).toInstance(new PoolingHttpClientConnectionManager()); bind(ScheduledExecutorService.class).toInstance(Executors.newSingleThreadScheduledExecutor()); bind(CalendarServiceData.class).toProvider(CalendarServiceDataProvider.class).in(Scopes.SINGLETON); bind(GtfsRelationalDao.class).toProvider(GtfsRelationalDaoProvider.class).in(Scopes.SINGLETON); bind(TimeZone.class).annotatedWith(AgencyTimeZone.class).toProvider(AgencyTimeZoneProvider.class) .in(Scopes.SINGLETON);/*w w w. j a v a 2 s . co m*/ }
From source file:org.petalslink.dsb.federation.core.server.RemoteCheckerServiceImpl.java
/** * //from w w w . ja v a 2 s . c om */ public RemoteCheckerServiceImpl(FederationServer server, PeerChecker peerChecker) { this.server = server; this.peerChecker = peerChecker; this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); }
From source file:com.linkedin.kmf.services.GraphiteMetricsReporterService.java
public GraphiteMetricsReporterService(Map<String, Object> props, String name) throws SocketException, UnknownHostException { _name = name;//from ww w .ja va 2 s. c o m GraphiteMetricsReporterServiceConfig config = new GraphiteMetricsReporterServiceConfig(props); _metricNames = config.getList(GraphiteMetricsReporterServiceConfig.REPORT_METRICS_CONFIG); _reportIntervalSec = config.getInt(GraphiteMetricsReporterServiceConfig.REPORT_INTERVAL_SEC_CONFIG); _executor = Executors.newSingleThreadScheduledExecutor(); _metricNamePrefix = config.getString(GraphiteMetricsReporterServiceConfig.REPORT_GRAPHITE_PREFIX); _graphiteClient = GraphiteClientFactory.defaultGraphiteClient( config.getString(GraphiteMetricsReporterServiceConfig.REPORT_GRAPHITE_HOST), config.getInt(GraphiteMetricsReporterServiceConfig.REPORT_GRAPHITE_PORT)); }