[prev in list] [next in list] [prev in thread] [next in thread]
List: log4j-cvs
Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/test MDCStress.java
From: ceki () apache ! org
Date: 2001-08-06 19:40:29
[Download RAW message or body]
ceki 01/08/06 12:40:29
Modified: src/java/org/apache/log4j MDC.java
src/java/org/apache/log4j/test MDCStress.java
Added: src/java/org/apache/log4j/helpers ThreadLocalMap.java
Log:
Added missing helpers/ThreadLocalMap.java
Corrected NullPointerExceptionProblem in helpers/ThreadLocalMap.java
Revision Changes Path
1.3 +15 -4 jakarta-log4j/src/java/org/apache/log4j/MDC.java
Index: MDC.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/MDC.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MDC.java 2001/08/06 19:29:19 1.2
+++ MDC.java 2001/08/06 19:40:29 1.3
@@ -1,23 +1,34 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
-
package org.apache.log4j;
import java.util.Hashtable;
import org.apache.log4j.helpers.ThreadLocalMap;
+/**
+
+
+ @author Ceki Gülcü
+ */
public class MDC {
final static ThreadLocalMap context = new ThreadLocalMap();
- static final int HT_SIZE = 11;
+ static final int HT_SIZE = 7;
static
public
void put(String key, Object o) {
Hashtable ht = (Hashtable) context.get();
if(ht == null) {
- System.out.println("Creating new ht. [" + Thread.currentThread().getName()+
- "]");
+ //System.out.println("Creating new ht. [" + Thread.currentThread().getName()+
+ // "]");
ht = new Hashtable(HT_SIZE);
context.set(ht);
}
1.1 jakarta-log4j/src/java/org/apache/log4j/helpers/ThreadLocalMap.java
Index: ThreadLocalMap.java
===================================================================
package org.apache.log4j.helpers;
import java.util.Hashtable;
final public class ThreadLocalMap extends InheritableThreadLocal {
public
final
Object childValue(Object parentValue) {
Hashtable ht = (Hashtable) parentValue;
if(ht != null) {
return ht.clone();
} else {
return null;
}
}
public
final
void finalize() throws Throwable {
System.out.println("finalize called. ["+Thread.currentThread().getName()+"]");
super.finalize();
}
}
1.3 +2 -7 jakarta-log4j/src/java/org/apache/log4j/test/MDCStress.java
Index: MDCStress.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/MDCStress.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MDCStress.java 2001/08/06 19:29:19 1.2
+++ MDCStress.java 2001/08/06 19:40:29 1.3
@@ -9,6 +9,7 @@
public class MDCStress extends Thread {
static Category root = Category.getRoot();
+ static Category log = Category.getInstance(MDCStress.class);
static Random random = new Random(17);
@@ -30,7 +31,6 @@
if(args.length != 1) {
usage();
}
-
try {
maxThreads = Integer.parseInt(args[0]);
}
@@ -58,7 +58,6 @@
}
-
static
void usage() {
System.err.println( "Usage: "+MDCStress.class + " maxThreads");
@@ -74,9 +73,7 @@
synchronized(MDCStress.class) {
n = maxThreadsConstained(n);
- root.debug("Creating " + n+ " child MDCStress threads.");
for(int i = 0; i < n; i++) {
- root.debug("New MDCStress, threadCounter = " + (++threadCounter));
new MDCStress(depth+1).start();
}
}
@@ -92,10 +89,9 @@
public
void run() {
MDC.put("depth", new Integer(depth));
- System.out.println("depth="+MDC.get("depth"));
+ log.debug("Entered run()");
int loopLength = randomInt(LOOP_LENGTH);
- root.debug("In run loop.debug( loopLength = "+loopLength);
int createIndex = loopLength/2;
@@ -110,7 +106,6 @@
threadCounter--;
root.debug( "Exiting run loop. " + threadCounter);
if(threadCounter <= 0) {
- root.debug( "Notifying [main] thread.");
MDCStress.class.notify(); // wake up the main thread
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-cvs-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic