vijay1440 Posted May 1, 2008 Share Posted May 1, 2008 Hi,I want to know how can we make the threads wait for an Object. Can you please give any suggestions?Thank you very much,Vijay Link to comment Share on other sites More sharing options...
jesh Posted May 1, 2008 Share Posted May 1, 2008 Conceptually, one suggestion would be that you make the thread check for some state (i.e. the object is loaded), if it isn't there, sleep for a bit. When it stops sleeping, check for the state. If it isn't there, sleep for a bit.pseudo-code: private void WaitForState(){ if(object is null) { sleep(); WaitForState(); }} Link to comment Share on other sites More sharing options...
vijay1440 Posted May 7, 2008 Author Share Posted May 7, 2008 Thank you very much for the suggestion. I guess this may work. And I have something else in mind. Shall we have some method on object like wait, which we can invoke to wait till it is not used by anyone? Conceptually, one suggestion would be that you make the thread check for some state (i.e. the object is loaded), if it isn't there, sleep for a bit. When it stops sleeping, check for the state. If it isn't there, sleep for a bit.pseudo-code:private void WaitForState(){ if(object is null) { sleep(); WaitForState(); }} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.