public class SynUtils {
static List<String> listSyn=new ArrayList<~>();
public static void unSyn(String str){
synchronized (listSyn) {
listSyn.remove(str);
}
}
public static boolean addSyn(String str) {
synchronized (listSyn) {
if(listSyn.contains(str)) return false;
listSyn.add(str);
return true;
}
}
public static boolean addSyn2(String str, long time) {
synchronized (listSyn) {
if(listSyn.contains(str)) {
if(time <= 0) return false;
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
return addSyn2(str, time-300);
}
listSyn.add(str);
return true;
}
}