hi geeks, i just m workin on a project for Messenger development. My problem is -- 1)Whether calling the same Static method from multiple Threads result in loss of data or deadlock??? I want to call a method called ---- Server.processMessage(Stringmsg) which is static method of server class.Will my message be lost with multiple threds. 2)If yes - then wats the solution? plz help...i need it in job tomorrow thanx samabhik 2)
Hi, Welcome to JavaRanch... I think. I'm not sure I'm too thrilled with the sound of your display name; given that it doesn't match your signature, I suspect it's not a real name at all. You might want to have a look at our naming policy and then make some adjustments here. Now, regarding your problem: the answer is "it depends." A class has to be designed properly to be used in a multithreaded environment. The answers to your questions depend on how the class was meant to be used. After you've fixed your display name, you might want to post some more details in a reply to this thread.
well...mr.Hill, m new to javaranch... still,i dint get wat u meant however... apart from my signature thing, wat is most important for me is the solution of the above problem...so if u can,kindly provide help... my question is --- Can I call a Static method --- Server.processMessage(String msg) [it processes the client messages for per socket] from multiple Threads.Will I lose any data? or result in deadlock? kindly help
author and iconoclast
As to your question, I thought I answered it pretty clearly: if the method was designed to be used in a multithreaded environment, then it will work fine. If it wasn't, then there is certainly a possibility that you'll get data loss. If it was designed for multithreaded use, but badly so, then you may see deadlocks. As I said, it depends. [ April 20, 2004: Message edited by: Ernest Friedman-Hill ]