代码如下:- //开始
- for (int i = 0; i < fList.size(); i++) {
-
- final List<FndMenuEntriesIntDto> sortList = fndMenuEntriesIntDao.getListByMenuId(fList.get(i).getMenuId(), versionId);
-
- new Thread(new Runnable() {
- @Override
- //线程1
- public void run() {
- for (int i = 0; i < sortList.size(); i++) {
- doSomeThing1();
- }
- }
- }).start();
-
- new Thread(new Runnable() {
- @Override
- //线程2
- public void run() {
- for (int i = 0; i < sortList.size(); i++) {
- doSomeThing2();
- }
- }
- }).start();
- }
-
- }
复制代码 doSomeThing1();和doSomeThing2();里执行的业务不一样,所需的时间也不同。
开始的循环处会等线程1和线程2都执行完再执行下一次循环码?
|