Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Super Contributor
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

How to lock a value like ReentrantLock??


Avoid missing reading a value.



Try to lock a value, after value is wrote into a report. Unlock will be active.


If anyone knows how to do that, please share your idea.


Thanks your attention.



-Fight with BB10
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to lock a value like ReentrantLock??

As I understand this, the basic idea here is that you hold the lock while you are processing and need exclusive access to some resource.  You can do the same sort of thing using synchronized blocks of code, you just need to make sure that all the Threads are using a shared Object. 


The other way this could be used and the way you seem to be trying to use it here, is as a notification mechanism.  In that case this is replacing a wait/notify.  The Server thread has an object that it will 'wait' on.  Client Threads will 'notify' this object when they have added processing for the Server thread to work on. 


Have I understood the question?