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)
greenhorn
Ernest Friedman-Hill
author and iconoclast
Marshal
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
Ernest Friedman-Hill
author and iconoclast
Marshal
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 ]
Yaroslav Chinskiy
Ranch Hand
Joined: Jan 09, 2001
Posts: 147
posted
0
one of the first thing I would try is to synchronize the method.
Roshan Lal
Ranch Hand
Joined: Nov 13, 2001
Posts: 64
posted
0
Originally posted by Ernest Friedman-Hill: 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...
Ernest, This looks a very real name to me! Apart from Captalizing the first letters, there is absolutely nothing wrong with this name. Hope that helps Roshan
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.