Skip to content

Instantly share code, notes, and snippets.

@suyuanhxx
Last active January 23, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suyuanhxx/baf7f049381426dc1ff9bd7d376f9164 to your computer and use it in GitHub Desktop.
Save suyuanhxx/baf7f049381426dc1ff9bd7d376f9164 to your computer and use it in GitHub Desktop.
public class LockTest {
@Autowired
private LockService lockService;
@Test
public void testGetKey throws Exception {
for (int i = 0; i < 10; i++) {
final int request = i;
new Thread(() -> {
String result = lockService.getKeyByrequestId(request);
System.out.println("thread result is: " + result + " and thread is: " + request);
}).start();
}
// 等待所以线程执行完毕,junit不支持异步
Thread.sleep(20000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment