1 13 package org.aspectj.runtime.internal.cflowstack; 14 15 import java.util.Stack ; 16 17 public class ThreadStackFactoryImpl implements ThreadStackFactory { 18 19 private static class ThreadStackImpl extends ThreadLocal implements ThreadStack { 20 public Object initialValue() { 21 return new Stack (); 22 } 23 public Stack getThreadStack() { 24 return (Stack )get(); 25 } 26 } 27 28 public ThreadStack getNewThreadStack() { 29 return new ThreadStackImpl(); 30 } 31 32 private static class ThreadCounterImpl extends ThreadLocal implements ThreadCounter { 33 34 public Object initialValue() { 35 return new Counter(); 36 } 37 public Counter getThreadCounter() { 38 return (Counter)get(); 39 } 40 41 public void inc() { getThreadCounter().value++; } 42 public void dec() { getThreadCounter().value--; } 43 public boolean isNotZero() { return getThreadCounter().value!= 0; } 44 45 static class Counter { 46 protected int value = 0; 47 } 48 } 49 50 public ThreadCounter getNewThreadCounter() { 51 return new ThreadCounterImpl(); 52 } 53 54 } 55 | Popular Tags |