我正在使用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)
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如果它阻塞主线程并且不异步运行,我什么时候以及为什么应该使用它?