• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling method of a class which is locked  RSS feed

 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a class A which has a method which locks and another method which unlocks the thread.



Now I have another class, which is calling this start() and stop() at certain events. My doubt is, if class A is locked after start(), if I call stop() from the other class, will it work?
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried it? What does it say in the documentation for count down latch?
 
Paul Clapham
Sheriff
Posts: 22836
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s ravi chandran wrote:My doubt is, if class A is locked after start()...


It isn't correct to say "class A is locked". In your code your CountDownLatch is an instance variable, so there's one latch for each instance of the class. And as for calling those methods from another class, the fact of what code is calling a method is never relevant in Java to how that method works.

As for whether some code will do what you think it will do (i.e. what you said "will it work") the best way to do that is to actually write that code and run it. In this case that shouldn't be too hard, should it? Why not give it a try?
 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a seperate service used to stop all processes. I saw till now that it was not shutting down and the process was being killed. Then i found my stop method was not incrementing the countdown. I added it. But the service will run next monday only. So i wanted to get a clear picture.
When the latch is blocked, it holds the class execution also, is it right?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!