- 博客(9)
- 收藏
- 关注
原创 几核几线程咋理解(转)
物理CPU物理CPU就是计算机上实际配置的CPU个数。在linux上可以打开cat /proc/cpuinfo 来查看,其中的physical id就是每个物理CPU的ID,你能找到几个physical id就代表你的计算机实际有几个CPU。在linux下可以通过指令 /proc/cpuinfo | grep ‘physical id’查看cpu核数核数就是指CPU上集中的处理数据的cpu核心个数,单核指cpu核心数一个,双核则指的是两个。通常每个CPU下的核数都是固定的,比如你的计算机有两个.
2020-08-27 09:15:20
3578
原创 String StringBuffer StringBuilder 性能比较
for (int k = 0 ; k < 10; k++){ long start = System.nanoTime(); String str=""; for (int j = 0; j <100;j++){ for (int i = 0; i < 100;i++){ str = str+String.valueOf(i); } } long end = System.nanoTime.
2020-07-30 16:42:52
224
原创 为何 handlerThread.getLooper不会返回null
HandlerThread的使用方法如下:HandlerThread handlerThread = new HandlerThread("myTest");handlerThread.start();Looper looper = handlerThread.getLooper();Handler handler = new Handler(looper);为何getLooper方法不会返回空指针呢?public Looper getLooper() { if (!isAl
2020-07-22 13:52:32
1231
原创 单例实现
方案一:public class SingleInstanceTest { private static volatile SingleInstanceTest mInstance; private SingleInstanceTest(){ } public static SingleInstanceTest getInstance(){ if (mInstance == null){ synchronized (Sin
2020-07-15 10:50:16
141
1
原创 注解限制参数类型
import androidx.annotation.IntDef;public class MyTest {public static final int VISIBLE = 1;public static final int INVISIBLE =2; @IntDef({VISIBLE,INVISIBLE}) @Retention(RetentionPolicy.SOURCE) @Target(ElementType.PARAMETER) public @i.
2020-07-14 14:56:05
2614
原创 软引用使用的一个注意点
BitmapSoftReference bitmapSoftRef = new SoftReference<Bitmap>();if(bitmapSoftRef.get() != null){ imageView.setImageBitmap(bitmapSoftRef.get());}合适的做法为:Bitmap bitmap =bitmapSoftRef.get();if(bitmap != null){ imageView.setImageBitm...
2020-07-14 09:18:16
175
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人