public static void main(String[] args) {  
            ExecutorService exec = Executors.newCachedThreadPool();  
            TestSemaphore t = new TestSemaphore();  
            final BoundedHashSet<String> set = t.getSet();  
      
            for (int i = 0; i < 3; i++) {//三个线程同时操作add  
                exec.execute(new Runnable() {  
                    public void run() {  
                        try {  
                            set.add(Thread.currentThread().getName());  
                        } catch (InterruptedException e) {  
                            e.printStackTrace();  
                        }  
                    }  
                });  
            }  
      
            for (int j = 0; j < 3; j++) {//三个线程同时操作remove  
                exec.execute(new Runnable() {  
                    public void run() {  
                        set.remove(Thread.currentThread().getName());  
                    }  
                });  
            }  
            exec.shutdown();  
        }