How do you use "synchronized" blocks?

Is there other way to prevent next thread to access the resource with out using "synchronized" blocks?

Questions by sathireddy   answers by sathireddy

Showing Answers 1 - 11 of 11 Answers

Prem Sagar

  • Mar 22nd, 2006
 

Singleton design pattern is one solution i hope..

  Was this answer useful?  Yes

satya krishna

  • Mar 27th, 2006
 

with out synchronisation concept we can not stop next thread to access the resource.

  Was this answer useful?  Yes

Deepa

  • Mar 31st, 2006
 

dear friend,

singleton class is used to create a single object for a class and is most secured class, but it do not support siglethreaded model

you can block the next thread without using sinchronize method by implementing single threaded model interface.

  Was this answer useful?  Yes

Kirti

  • Apr 17th, 2006
 

Hi Deepa

 can you please tell how the single threaded model can be implemented?

  Was this answer useful?  Yes

Bala

  • Apr 29th, 2006
 

We can't use wait notify without a monitor... and it is achieved by synchronization.

  Was this answer useful?  Yes

Nishant jain

  • May 7th, 2006
 

there is a way to do so, but its a bit complex and has be done by a programmer.

Well u can implement the semaphore architecture using the the semaphore variable.

this can be done as following:

take a boolean variable which can be accesed by one thread at a time and place the code that is to be shared inside that block with test condition on that variable. let one thread hold that code at a time and setting the variable to false and after when it release the code setting the variable to true.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions