From 6d5c75b52005620858d0c5231440f578d9222c7e Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 15 Aug 2011 17:40:48 -0400 Subject: Improving performance documentation. --- src/com/iciql/util/StatementLogger.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/com/iciql/util/StatementLogger.java b/src/com/iciql/util/StatementLogger.java index 95d644a..0504c98 100644 --- a/src/com/iciql/util/StatementLogger.java +++ b/src/com/iciql/util/StatementLogger.java @@ -18,6 +18,8 @@ package com.iciql.util; import java.text.DecimalFormat; import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; /** @@ -43,6 +45,7 @@ public class StatementLogger { void logStatement(StatementType type, String statement); } + private static final ExecutorService EXEC = Executors.newSingleThreadExecutor(); private static final Set LISTENERS = Utils.newHashSet(); private static final StatementListener CONSOLE = new StatementListener() { @@ -121,12 +124,13 @@ public class StatementLogger { logStatement(StatementType.SELECT, statement); } - private static void logStatement(StatementType type, String statement) { - for (StatementListener listener : LISTENERS) { - try { - listener.logStatement(type, statement); - } catch (Throwable t) { - } + private static void logStatement(final StatementType type, final String statement) { + for (final StatementListener listener : LISTENERS) { + EXEC.execute(new Runnable() { + public void run() { + listener.logStatement(type, statement); + } + }); } } -- cgit v1.2.3