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

[1213 byte] By [southamptona] at [2007-10-3 9:22:29]
# 1
tell us in english where the "semaphore" part starts, and what error if any it gives when it dies
mkoryaka at 2007-7-15 4:36:09 > top of Java-index,Java Essentials,Java Programming...
# 2
it does not give an error all it does is executes then dies it wont process the print part but it does on all the other threads
southamptona at 2007-7-15 4:36:09 > top of Java-index,Java Essentials,Java Programming...
# 3
how do start this peice of code?give peice of code that starts this
mkoryaka at 2007-7-15 4:36:09 > top of Java-index,Java Essentials,Java Programming...
# 4

> it does not give an error all it does is executes then dies it wont process the

> print part

Based on what you've posted there's no reason why it must "process the print

part". If Integer.parseInt() throws an exception it will do whatever you specify

when you catch that error - which might be to "not give an error at all".

[Edit] Print the thread name.

pbrockway2a at 2007-7-15 4:36:09 > top of Java-index,Java Essentials,Java Programming...