• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to simulate multi-thread to test Data ?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic