TestRunnable1.java 644 B

1234567891011121314151617181920212223
  1. package com.sf.utils.thread;
  2. import com.sf.utils.HttpUtils;
  3. public class TestRunnable1 {
  4. public static void main(String[] args) {
  5. String url = "http://localhost:8080/seckill?userId=111&goodsId=1";
  6. for (int i = 0; i < 20; i++) {
  7. Thread thread = new Thread(new Runnable() {
  8. @Override
  9. public void run() {
  10. try {
  11. HttpUtils.seckill(url);
  12. } catch (Exception e) {
  13. throw new RuntimeException(e);
  14. }
  15. }
  16. });
  17. thread.start();
  18. }
  19. }
  20. }