2 * JCarder -- cards Java programs to keep threads disentangled
4 * Copyright (C) 2006-2007 Enea AB
5 * Copyright (C) 2007 Ulrik Svensson
6 * Copyright (C) 2007 Joel Rosdahl
8 * This program is made available under the GNU GPL version 2, with a special
9 * exception for linking with JUnit. See the accompanying file LICENSE.txt for
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE.
17 package com.enea.jcarder.agent;
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 //import net.jcip.annotations.ThreadSafe;
24 * Each instance of this class keeps a list of entered monitors for a thread.
26 * Note that this class is a ThreadLocal and therefore each thread will have its
31 final class ThreadLocalEnteredMonitors
32 extends ThreadLocal<ArrayList<EnteredMonitor>> {
34 public ArrayList<EnteredMonitor> initialValue() {
35 return new ArrayList<EnteredMonitor>();
38 Iterator<EnteredMonitor> getIterator() {
39 return get().iterator();
42 EnteredMonitor getFirst() {
43 ArrayList<EnteredMonitor> list = get();
51 void addFirst(EnteredMonitor enteredMonitor) {
52 get().add(0, enteredMonitor);