1 5 package com.opensymphony.oscache.base; 6 7 import com.opensymphony.oscache.general.GeneralCacheAdministrator; 8 9 import junit.framework.TestCase; 10 11 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 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 35 36 class Client extends Thread { 37 private static final int MAX_ITERATIONS = 1000; 38 private GeneralCacheAdministrator cache; 39 private int id; 40 41 public Client(int newId, GeneralCacheAdministrator newCache) { 42 super(); 43 id = newId; 44 cache = newCache; 45 } 46 47 public void run() { 48 for (int i = 0; i < MAX_ITERATIONS; i++) { 49 51 cache.putInCache(Integer.toString(id), "Some interesting data", new String [] { 52 "GLOBAL_GROUP" 53 }); 54 55 cache.flushGroup("GLOBAL_GROUP"); 57 } 58 } 59 } 60 | Popular Tags |