Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. class MySafeList extends ArrayList<Double>{
  4.  
  5. static ArrayList<Double> mySafeList;
  6.  
  7. public boolean add(Double d){
  8. mySafeList.add(d);
  9. return true;
  10. }
  11.  
  12. public int size(){
  13. return mySafeList.size();
  14. }
  15.  
  16. public Double get(int i){
  17. return mySafeList.get(i);
  18.  
  19. }
  20.  
  21. static boolean stressTest(int n, int m){
  22. Thread threads[] = new Thread[n]; //El nombre de tu variable se llama "threads"
  23. try{
  24. for(int i=0; i<n; i++){
  25. threads[i] = new Thread(new ThreadTest(1));
  26. threads[i].start();
  27. for(int j=0; j<m;j++){
  28. Double d = new Double((double) j);
  29. mySafeList.add(d);
  30. }
  31. }
  32. return true;
  33. }catch(Exception e){
  34. return false;
  35. }
  36. }
  37.  
  38. public static void main(String[] args) {
  39. MySafeList safeList = new MySafeList();
  40. stressTest(2,4);
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement