| Author |
testing locks.
|
Prakash Krishnamurthy
Ranch Hand
Joined: Oct 08, 2002
Posts: 154
|
|
I am trying to test my locks. I have a test class that spawns a few threads. Each thread represents a client which is booking the same flight. The intention is to have multiple clients book the same flight at the same time so that I know if my locking and unlocking algorithm is working or not. The problem is, on the client side I have the thread name with the output, so I know which client is doing what. But on the server side, I am not able to associate the clients with their respective threads on the server. Any ideas how I can go about this?
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10815
|
|
Hi Prakash, Depending on how readable you want your output to be, you have some choices: Within the thread, if you simply do a System.out.print(this) you should get at least some sort of unique identifier (possibly the hashcode for the thread), and possibly a whole lot of debugging information as well. Or, overide the constructor (you are doing that anyway for your tests), and pass in a unique identifier: You can even override the toString() method to make it nicer: Does any of this help? If not please give more details of what you are trying to do. Regards, Andrew
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Prakash Krishnamurthy
Ranch Hand
Joined: Oct 08, 2002
Posts: 154
|
|
Andrew: Probably, I wasn't too clear about my question. Let me re-ask this question. On the clientside when i run my threadtest class to test my locks I get the following output On the server though, I get this On the client I am clear about the thread name. But, on the server I am not sure which thread is locking and which thread is unlocking. Like, on the server side it says . "The record number that is about to be locked is 1 Somebody is accessing this record, Please wait! Just about to enter the unlock for record no 1" It is not clear to me which thread does this corrrespond to... I am going to try just doing and see if things are clear on the server side. I think my question did get answered, though. I was just trying to make sure I had explained the problem well.:-) [ April 16, 2003: Message edited by: Prakash Krishnamurthy ]
|
 |
 |
|
|
subject: testing locks.
|
|
|