diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 077e73ba..8298240d 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -342,7 +342,7 @@ public final class Application implements Runnable { String ignoreDirs; Initializer(String dirs) { - super("INIT-" + name); + super(name + "-init"); ignoreDirs = dirs; } @@ -489,7 +489,7 @@ public final class Application implements Runnable { releaseEvaluator(eval); } - worker = new Thread(this, "Worker-" + name); + worker = new Thread(this, name + "-worker"); worker.setPriority(Thread.NORM_PRIORITY + 1); worker.start(); } diff --git a/src/helma/framework/core/RequestEvaluator.java b/src/helma/framework/core/RequestEvaluator.java index a5fcaff3..232c3738 100644 --- a/src/helma/framework/core/RequestEvaluator.java +++ b/src/helma/framework/core/RequestEvaluator.java @@ -79,6 +79,10 @@ public final class RequestEvaluator implements Runnable { // the exception thrown by the evaluator, if any. private volatile Exception exception; + // For numbering threads. + private int threadId; + + /** * Create a new RequestEvaluator for this application. * @param app the application @@ -668,7 +672,7 @@ public final class RequestEvaluator implements Runnable { if ((thread == null) || !thread.isAlive()) { // app.logEvent ("Starting Thread"); - thread = new Thread(app.threadgroup, this); + thread = new Thread(app.threadgroup, this, app.getName() + "-" + (++threadId)); thread.setContextClassLoader(app.getClassLoader()); thread.start(); } else { diff --git a/src/helma/util/Logger.java b/src/helma/util/Logger.java index c24554af..32beccc6 100644 --- a/src/helma/util/Logger.java +++ b/src/helma/util/Logger.java @@ -143,7 +143,9 @@ public class Logger implements Log { // has gone. the 2000 entries threshold is somewhat arbitrary. if (entries.size() < 2000) { String message = msg == null ? "null" : msg.toString(); - entries.add(new Entry(dateCache, level, message, exception)); + Thread thread = Thread.currentThread(); + String threadId = "[" + thread.getName() + "] "; + entries.add(new Entry(dateCache, level, message, threadId, exception)); } } @@ -164,6 +166,7 @@ public class Logger implements Log { Entry entry = (Entry) entries.remove(0); writer.print(entry.date); writer.print(entry.level); + writer.print(entry.threadId); writer.println(entry.message); if (entry.exception != null) entry.exception.printStackTrace(writer); @@ -294,13 +297,14 @@ public class Logger implements Log { } class Entry { - final String date, level, message; + final String date, level, message, threadId; final Throwable exception; - Entry(String date, String level, String message, Throwable exception) { + Entry(String date, String level, String message, String threadId, Throwable exception) { this.date = date; this.level = level; this.message = message; + this.threadId = threadId; this.exception = exception; } }