Forums Register Login

hello i am mohandodderi very new member in the family

+Pie Number of slices to send: Send
hello , if we have synchronized code/method in the middle of the statements sequence ,what will happen in multithreaded environment.how does the execution takes place ,ie if one thread executing that synchronized code/method ,what other paralally executing thread will be doing , is there any problem in the performance ,ie slowlness in the execution ...
pls help me
+Pie Number of slices to send: Send
Hi Mohan, welcome to Javaranch.

This particular forum is for Servlets questions. Your question on Threads should be posted in a forum that handles Thread questions, So I am going to move this thread to that forum. Please try to keep your questions on topic to the forum that will best answer your questions.

Good Luck

Mark
+Pie Number of slices to send: Send
The synchronized block of code can only be executed by one thread at a time. Threads not waiting to execute that block are unaffected. So make the synchronzed block as small as possible. For example, if the only data that needs to be thread safe is in an ArrayList, then synchronized block should only contain code that accesses that ArrayList - no more.
+Pie Number of slices to send: Send
 


"An anology I have used before is that of a movie theater. You don't expect the movie to take longer just because a few more people come in to see it today." - Frank Carver



Mark, of what is the above quote an anology?
Willie Smits can speak 40 languages. This tiny ad can speak only one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 611 times.
Similar Threads
Lock/Unlock
Thread Question
synchronized context
synchronized
Synchronized Thread Run Method
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:59:11.