summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/JavaClassGenerator_test.cpp
diff options
context:
space:
mode:
authorHugo Benichi <hugobenichi@google.com>2016-10-13 16:48:42 +0900
committerLorenzo Colitti <lorenzo@google.com>2017-01-26 18:51:49 +0900
commitd28766c74d3e5b7a272e3ad40660c46828d0cdf9 (patch)
tree44f2ee79b148dd9dab989f71829f90f1b117bd60 /tools/aapt2/java/JavaClassGenerator_test.cpp
parent1e19aefa6f9e2368f34745bc0eb38dc2618e4f06 (diff)
ConnectivityThread: use lazy holder idiom
This patch changes the way that the ConnectivityThread is lazily instantiated by using the "lazy initialization holder class idiom". The first code point that tries to obtain a reference to the unique ConnectivityThread instance will trigger the creation of the Singleton class, which will guarantee a thread-safe initialization of the static INSTANCE field inside Singleton according to the language specs. This is the Item #71 of Effective Java. The unique static instance of ConnectivityThread is not stored directly inside ConnectivityThread class but is stored in a static nested class. This is to avoid triggering the creation of that unique instance when Zygote does class preloading at phone startup. Otherwise this would lead to Zygote creating a new OS thread during preloading, which is a fatal error. Test: frameworks-wifi tests pass Bug: 26749700 Bug: 28537383 Bug: 32130437 (cherry picked from commit c4fe5d373caa9f53686e4d58e61394dd40558957) Change-Id: If13b363889a8e9396273a90c3d9f9421a48aecbc
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp')
0 files changed, 0 insertions, 0 deletions