public static void main(String[] args) { // TODO Auto-generated method stub ExpiryCache<String, String> emap = new ExpiryCache<String, String>(); emap.put("abc", "xyz"); emap.put("abc1", "xyz1"); TestSync ts = new TestSync(emap); ts.runThreads(); emap.getExpire().startExpiringIfNotStarted(); T3 th = new T3(emap); th.stTh(); }
@Override public void run() { // TODO Auto-generated method stub for (int i = 0; i < 10000; i++) { if (Thread.currentThread().getName().equalsIgnoreCase("t1")) cache.put("keyt1" + i, "valuet1" + i); else cache.put("keyt2" + i, "valuet2" + i); try { Thread.sleep(10); } catch (InterruptedException e) { } } }
@Override public void run() { // TODO Auto-generated method stub for (int i = 0; i < 100; i++) { System.out.println(cache.get("keyt1" + i)); System.out.println(cache.get("keyt2" + i)); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }