1 32 33 34 42 package stockonline.util; 43 44 import java.io.*; 45 import java.util.*; 46 47 51 public class Synch 52 { 53 private static int maxThreadCounter; 54 private static int threadCounter; 55 private static boolean go; 56 57 public Synch(int maxThreadCounter) 58 { 59 this.maxThreadCounter = maxThreadCounter; 60 this.threadCounter = 0; 61 this.go = false; 62 } 63 64 public synchronized void increase() 65 { 66 threadCounter++; 67 } 69 70 public static boolean setGo() 71 { 72 if(threadCounter>=maxThreadCounter) 73 { 74 go = true; 75 } 76 77 return go; 78 } 79 80 public synchronized boolean getGo() 81 { 82 return go; 83 } 84 85 public static void sleep(int val) 86 { 87 try { 88 Thread.sleep(val); 89 } catch(java.lang.InterruptedException ex) {} 90 } 91 } 92 93 | Popular Tags |