Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How can i test the lock situation?

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear fellows
I tried to test the deadlock situation.
I did domething like:
if(lock)
wait()
not
thread.sleep(timeout)
I testeing in the same machine with VAJ 4.0, with one server and two instance of the clients all executed from VAJ environment.
But looks like both clients waits for the timeout, the second one never go to wait() method.
I also implemented a Timer for the deadlock and I really don�t now how to test in the same machine.
Some advice ?
Thanks in advance
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must put the Thread.sleep(1000) outside
the synchronized block like this
synchronized (lockVector) {
wait()
}

Thread.sleep(1000)
Hope that helps
Enrico
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the command-line debugger (jdb) to test my locking scheme.
I ran two or three instances of the client app without the GUI -- as essentially my own test-harness. I ran each in the debugger. I set a breakpoint right after the lock()-call in each one.
That showed that when a given record was locked (by whichever client I'd started first), other clients indeed had to wait until I entered "continue" in the debugger in which the other one(s) was(were) running. That allowed the one(s) with the lock to release it, thereby giving the other(s) a chance to proceed -- realizing that there is contention sometimes (when more than one is waiting for the lock on a given record).
 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:
One of the Rancher suggested me to disable the unlock method, recompile and run it. I saw blocked message, but it froze my screen.
Another suggestion was quite good. Implement a delay Thread.sleep(...) at the begining of your unlock method. Happy testing. -Bal
 
Quick! Before anybody notices! Cover it up with this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic