16k words 15 mins.

# Terms Term Example Parameterized type List<String> Actual type parameter String Generic type List<E> Formal type parameter E Unbonded wildcard type List<?> Raw type List Bounded type parameter <E extends Number> Recursive type...
9.3k words 8 mins.

# 异常描述 引入穿山甲 SDK 后,编译运行时异常,堆栈如下 2023-08-06 23:08:51.659 32243-32243/com.maxim.wordcard.debug E/AndroidRuntime: FATAL EXCEPTION: main Process: com.maxim.wordcard.debug, PID: 32243 java.lang.RuntimeException: Unable to get provider com.bytedance.sdk.openadsdk.TTFileProvider:...
6.1k words 6 mins.

Observable.create(new Observable.OnSubscribe<Integer>() { @Override public void call(Subscriber<? super Integer> observer) { try { if (!observer.isUnsubscribed()) { for (int i = 1; i < 5; i++) { observer.onNext(i); }...
11k words 10 mins.

关于 AbstractQueuedSynchronizer 的源码分析,我以 ReentrantLock 为例,类图如上。 A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor lock accessed using synchronized methods and statements, but with extended capabilities. A ReentrantLock is owned by the thread last...
1.5k words 1 mins.

计数方式实现的旗语,一个旗语维护一组概念上的许可。每个线程 acquire 都会在必要时阻塞,直到有许可证可用,然后获取它,许可数量减一。每次释放都会增加一个许可,从而有可能释放阻塞在 acquire 的线程。不过, Semaphore 并不使用实际的许可对象;它只是对可用数量进行计数,并采取相应的行动。 如此 Semaphores 通常用于限制可以访问某些(物理或逻辑)资源的线程数量。也就是说,当你希望只有 permits 个线程可以并发访问这些资源是,通过 Semaphore (int permits, boolean fair) 实例化 permits 个许可资源,线程 aquire...
3.9k words 4 mins.

# Overview 一种同步辅助工具,允许一个或多个线程等待其他线程正在执行的一组操作完成。 A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes. CountDownLatch 以给定的计数初始化。await 方法会阻塞,直到当前计数因调用 CountDown 方法而归零,之后所有等待的线程都会被释放,并且 await 的任何后续调用都会立即返回。这是一种一次性现象 --...
9.3k words 8 mins.

本文的目的为掌握线程池的正确使用。如果英语水平不错,仅仅看类注释,半个小时就可以初步掌握如何正确使用了,但如果读懂源码相关的实现,则不仅可以辅助加深对注释描述的理解,也可以学习好的代码设计和实现。 # Overview An ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods. # Core and maximum pool sizes 在方法...
6.1k words 6 mins.

# Integer Representations 在学校教科书告诉我们原码,反码,补码的规则来计算正负数在计算机的表示。 原码:将一个整数,转换成二进制,就是其原码。 如单字节的 5 的原码为:0000 0101;-5 的原码为 1000 0101。 反码:正数的反码就是其原码;负数的反码是将原码中,除符号位以外,每一位取反。 如单字节的 5 的反码为:0000 0101;-5 的反码为 1111 1010。 补码:正数的补码就是其原码;负数的反码 + 1 就是补码。 如单字节的 5 的补码为:0000 0101;-5 的补码为 1111...
4.1k words 4 mins.

# 目录 单词卡片效果图 Android 单词卡片应用下载 下载安装 GoldenDict 应用 下载词库文件并放置在 GoldenDict 目录 #...
4.8k words 4 mins.

# 效果 # 代码实现 package com.maxim.openglimport android.content.Contextimport android.graphics.*import android.view.MotionEventimport android.view.Viewimport com.maxim.opengl.utils.Constantsimport com.maxim.opengl.utils.VLogimport kotlin.math.acosimport kotlin.math.asinimport kotlin.math.sqrtclass...