Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Another synchronized block question  RSS feed

 
Bindu Dharmavaram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following code.

In the above code, I started a thread to wait for sometime before it shuts down this process, by that time, returning the "shutdown success" String.
Seems like the thread start is happening before the return line. So, the system.exit(0) is happening before I can send out the return value.
My idea of having a synchronized block in run method that object has to perform the return before running the synchronized block in the run method of the kill thread. Does not seem to help.
Any suggestions as to how I can send the return value before exiting the program ?
Thanks
-Bindu
[Added CODE tags - PdH]
[ February 08, 2002: Message edited by: Peter den Haan ]
 
Bindu Dharmavaram
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add on,
Actually, the method shutdown is synchronized too.
So, by having another synchronized block within run method of the thread should complete the return statement, and then run the thread inside the inner block.
The process, which is listening on the return variable from this method is timing out not able to receive that return string. Hence, I think that the System.exit(0) in the run method is somehow executed before the return statement.
Is this normal behavior ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!