小编nik*_*shi的帖子

"defau1t:"(不是"默认值:")是标签的有效值?

为什么这段代码编译运行正常.我在l的地方写了defau1t而不是默认值1.

#include<stdio.h>
int main()
{
    int i=4;
    switch(i)
    {
        case 3:
        break;
        defau1t :
        break;      
    }
}
Run Code Online (Sandbox Code Playgroud)

c c++

9
推荐指数
2
解决办法
230
查看次数

未来 vs Completablefuture ? 对于这个用例 Completablefuture 会有什么不同吗?

我有四个服务。

One will give hotels which is matching to the query.
One will give City which is matching to the query.
One will give Airports which is matching to the query.
One will give Metro stations which is matching to the query.
Run Code Online (Sandbox Code Playgroud)

对于每个 HTTP 请求,我将命中这四个服务并合并来自四个服务的响应并返回。

所以我的示例代码就像

for(EntityGroups entityGroups: EntityGroups.values()){
            Callable<Response> callable = new XCallable(entityTypetoFetch, searchQuery);
            Future<List<Entity>> listFuture = executor.submit(callable);
            entityTypeAndFutureMap.put(entityTypetoFetch, listFuture);
        }
Run Code Online (Sandbox Code Playgroud)

在此之后,我在 for 循环中得到所有响应

trainStationList = entityTypeAndFutureMap.get(EntityGroups.TRAIN_STATION).get();
            landmarkEntities = entityTypeAndFutureMap.get(EntityGroups.LANDMARK_GROUP).get();
            cityEntities = entityTypeAndFutureMap.get(EntityGroups.CITY_GROUP).get();
            hotelEntities = entityTypeAndFutureMap.get(EntityGroups.HOTEL_GROUP).get();
Run Code Online (Sandbox Code Playgroud)

因为我希望所有列表合并并做出最终响应。我正在拨打阻塞电话。我只想合并这些列表并返回。如果我在这里使用 completablefuture 会有帮助吗? …

java multithreading future threadpool completable-future

6
推荐指数
1
解决办法
2326
查看次数

标签 统计

c ×1

c++ ×1

completable-future ×1

future ×1

java ×1

multithreading ×1

threadpool ×1