01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.oscache.base;
06:
07: import com.opensymphony.oscache.general.GeneralCacheAdministrator;
08:
09: import junit.framework.TestCase;
10:
11: /**
12: * DOCUMENT ME!
13: *
14: * @author $author$
15: * @version $Revision: 254 $
16: */
17: public class GroupConcurrencyProblemTestCase extends TestCase {
18: private static GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
19:
20: public static void main(String[] args) {
21: System.out.println("START");
22:
23: // Create some clients and start them running.
24: for (int i = 0; i < 100; i++) {
25: System.out.println("Creating thread: " + i);
26:
27: new Client(i, cache).start();
28: }
29:
30: System.out.println("END");
31: }
32: }
33:
34: /* Inner class to hammer away at the cache. */
35: class Client extends Thread {
36: private static final int MAX_ITERATIONS = 1000;
37: private GeneralCacheAdministrator cache;
38: private int id;
39:
40: public Client(int newId, GeneralCacheAdministrator newCache) {
41: super ();
42: id = newId;
43: cache = newCache;
44: }
45:
46: public void run() {
47: for (int i = 0; i < MAX_ITERATIONS; i++) {
48: /* Put an entry from this Client into the shared group.
49: */
50: cache.putInCache(Integer.toString(id),
51: "Some interesting data",
52: new String[] { "GLOBAL_GROUP" });
53:
54: // Flush that group.
55: cache.flushGroup("GLOBAL_GROUP");
56: }
57: }
58: }
|