tech

关于线程安全,有这么一段描述:

A class is thread-safe if it behaves correctly when accessed from multiple threads, regardless of the scheduling or interleaving of the execution of those threads by the runtime environment, and with no additional synchronization or other coordination on the part of the calling code.

即在多线程的环境下,无论线程如何被调度,线程间有怎样的交错,程序都能表现出正确的行为。

但仔细研究ArrayList的源码就会发现,它并不满足这一描述。

阅读更多

在实现单例模式时,如果未考虑多线程的情况,就容易写出下面的错误代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
public class Singleton {
private static Singleton uniqueSingleton;

private Singleton() {
}

public Singleton getInstance() {
if (null == uniqueSingleton) {
uniqueSingleton = new Singleton();
}
return uniqueSingleton;
}
}

阅读更多

因为想自己搭建博客又不想自己托管(不稳定,数据易丢,需自己处理扩容),所以这段时间研究了一下平台托管的博客,大概有两类方案:

  • WordPress.com(不是WordPress.org)
  • 静态博客生成器+托管平台

阅读更多

JWT(JSON Web Token)是一个开放标准(RFC 7519),它定义了一种紧凑且独立的方式,可以在各个系统之间用JSON作为对象安全地传输信息,并且可以保证所传输的信息不会被篡改。

阅读更多

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×