importjava.util.ArrayList;importjava.util.Random;publicclassMain{publicstaticvoidmain(Stringarg[])throwsException{Randomr=newRandom();ArrayList<Thread>threads=newArrayList<Thread>();Semaphores=newSemaphore(4);//create some threadsfor(inti=0;i<10;i++){MyThreadmt=newMyThread(r,i,s);threads.add(mt);}//start all the threadsfor(Threadt:threads){t.start();}}}