wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how to simulate multi-thread to test Data ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how to simulate multi-thread to test Data ?" Watch "how to simulate multi-thread to test Data ?" New topic
Author

how to simulate multi-thread to test Data ?

ZhiYuan Lin
Ranch Hand

Joined: Jun 30, 2003
Posts: 44
hi all
how to simulate multi-thread to test Data ? now i just have:
for (int i = 0; i < 100; i++)
new testThread().start();

//in testTeread
public void run() {
//do something such delete, add, find... Random
}
but how to do purposeful test?and how to test if my Data is thread safety and lock/unlock is working right?

thanks
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Here is one test. Start 20 threads, each trying to decrement a particular field of the same database record 200 times, in a loop. If at the end of the run the field value is reduced by exactly 4000, you pass.
Svetlana Koshkina
Ranch Hand

Joined: Jul 08, 2003
Posts: 108
It is my test (you have to modify some lines:
how you get your data and other stuff). It's very unfriendly to read and hostile to run(if your app. is at early stage, your file most likely will be corrupted at the end) just to give you an idea. You can mold it into anything you want.
It is earliest test that tests just implementation of data. Later I had for all kind of clients too.
ZhiYuan Lin
Ranch Hand

Joined: Jun 30, 2003
Posts: 44
thank you
hi Svetlana your code is help me much,thank you again
but it is random multi-thread test, i still want to know some approach to test purposeful , is it exist that can testify my Data
is safety?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to simulate multi-thread to test Data ?