小编Rar*_*y7-的帖子

Theme.MaterialComponents colorPrimary 不工作

我正在使用Theme.MaterialComponent,但它不会影响我的 actionBar,为什么?

样式文件

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowBackground">@color/windowBackground</item>
        <item name="android:textColor">@color/white</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

颜色文件

<resources>
    <color name="colorPrimary">#801336</color>
    <color name="colorPrimaryDark">#510a32</color>
    <color name="colorAccent">#ee4540</color>
    <color name="windowBackground">#2d142c</color>

    <color name="white">#FFF</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

android material-design

4
推荐指数
1
解决办法
2037
查看次数

为什么这个 Future 的方法会阻塞主线程?

ExecutorService executor = Executors.newFixedThreadPool(2);

Future<Integer> calculate(Integer input) {
    return executor.submit(() -> {
        Thread.sleep(3000);
        return input * input;
    });
}

public static void main(String []args) throws Exception {
    Main m = new Main();
    System.out.println(m.calculate(5).get());
    System.out.println("Main");
Run Code Online (Sandbox Code Playgroud)

我们使用 2 个线程将 Callable 提交给 Executor,但是当我告诉m.calculate(5).get()它阻塞主线程时。所以,我不明白,Future如果它阻塞主线程并且不异步运行,我什么时候以及为什么应该使用它?

java multithreading future

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

标签 统计

android ×1

future ×1

java ×1

material-design ×1

multithreading ×1