小编zac*_*ode的帖子

如何从 git 上丢失的提交中恢复代码?

我使用 回滚到之前的提交git checkout "commit number1"。然后我没有意识到我正在提交而不是在任何分支上,所以我在这里进行了更改并将代码提交到"commit number1". 现在我切换到功能分支。feature/branch1我没有看到任何代码。如果我切换回"commit Number1",我也看不到那里的代码。我是否脱离了任何事物?

$ git checkout 49da8b4d431

Note: checking out '49da8b4d431'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by …
Run Code Online (Sandbox Code Playgroud)

git

3
推荐指数
1
解决办法
1451
查看次数

如何迭代 Future<List> 对象?

我的call()方法的返回值List<Person>。MyCallable 类如下所示:

public class MyCallable implements Callable<List<Person>> {

    public List<Person> call() throws Exception {

           ...
    
           return list;
    }

    public MyCallable(List<Account> accountList) {
        super();
    }
}
Run Code Online (Sandbox Code Playgroud)

下面是我在 CallableFuture 类中编写的代码:

ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
List<Future<List<Person>>> list = new ArrayList<Future<List<Person>>>();
for (int i = 0; i < 20; i++) {
    Callable<List<Person>> worker = new MyCallable(accountList);
    Future<List<Person>> submit = executor.submit(worker);
    for(Future<List<Person>> :list){
        //list.add(submit);
    }
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何迭代list并添加submit到它。我这样做对吗?

java concurrency multithreading list

2
推荐指数
1
解决办法
5592
查看次数

标签 统计

concurrency ×1

git ×1

java ×1

list ×1

multithreading ×1