Search in sources :

Example 1 with DaemonThreadFactory

use of com.mongodb.internal.thread.DaemonThreadFactory in project mongo-java-driver by mongodb.

the class Mongo method createCursorCleaningService.

private ExecutorService createCursorCleaningService() {
    ScheduledExecutorService newTimer = Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory("CleanCursors"));
    newTimer.scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            cleanCursors();
        }
    }, 1, 1, SECONDS);
    return newTimer;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DaemonThreadFactory(com.mongodb.internal.thread.DaemonThreadFactory)

Example 2 with DaemonThreadFactory

use of com.mongodb.internal.thread.DaemonThreadFactory in project mongo-java-driver by mongodb.

the class DefaultConnectionPool method createMaintenanceTimer.

private ExecutorService createMaintenanceTimer() {
    if (maintenanceTask == null) {
        return null;
    } else {
        ScheduledExecutorService newTimer = Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory("MaintenanceTimer"));
        newTimer.scheduleAtFixedRate(maintenanceTask, settings.getMaintenanceInitialDelay(MILLISECONDS), settings.getMaintenanceFrequency(MILLISECONDS), MILLISECONDS);
        return newTimer;
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DaemonThreadFactory(com.mongodb.internal.thread.DaemonThreadFactory)

Example 3 with DaemonThreadFactory

use of com.mongodb.internal.thread.DaemonThreadFactory in project mongo-java-driver by mongodb.

the class MongoClient method createCursorCleaningService.

private ExecutorService createCursorCleaningService() {
    ScheduledExecutorService newTimer = Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory("CleanCursors"));
    newTimer.scheduleAtFixedRate(this::cleanCursors, 1, 1, SECONDS);
    return newTimer;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DaemonThreadFactory(com.mongodb.internal.thread.DaemonThreadFactory)

Aggregations

DaemonThreadFactory (com.mongodb.internal.thread.DaemonThreadFactory)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3