Semaphore
publicvoid run()
{
sharedWindow sw =new sharedWindow();
String name = Thread.currentThread().getName();
int j = Integer.parseInt(name.substring(7,8));
for(int i=0; i<10; i++)
{
if (j==1)
{
System.out.println("RUNNING");
shaVar=shaVar+1;
x.P();
System.out.println("i got passed the x");
sw.printMessage((" "+s)+ shaVar);
x.V();
}
else
{
System.out.println("Not Updated"+name);
}
}
my problem is that the code dyes when it hits the semaphore...any ideas why? note: i am not after code please tell me in english why it does not work

