• Post Reply Bookmark Topic Watch Topic
  • New Topic

hello i am mohandodderi very new member in the family

 
Mohan D S
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rovas Kram
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rovas Kram
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!