Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Java concurrency guidelines.pdf
Скачиваний:
16
Добавлен:
23.05.2015
Размер:
1.35 Mб
Скачать

TPS04-J

public final class DiaryPool {

//...

DiaryPool() {

exec = new CustomThreadPoolExecutor(NoOfThreads, NoOfThreads,

10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); diary = new Diary();

}

//...

}

5.5.5Exceptions

TPS04-EX1: There is no need to reinitialize a ThreadLocal object that does not change state after initialization. For example, there may be only one type of database connection represented by the initial value of the ThreadLocal object.

5.5.6Risk Assessment

Objects using ThreadLocal data and executed by different threads in a thread pool without reinitialization might be in an unexpected state when reused.

Guideline

Severity

Likelihood

Remediation Cost

Priority

Level

TPS04- J

medium

probable

high

P4

L3

5.5.7References

[Arnold 2006]

Section 14.13, “ThreadLocal Variables”

[Sun 2009b]

class java.lang.ThreadLocal<T>

CMU/SEI-2010-TR-015 | 143

TPS04-J

CMU/SEI-2010-TR-015 | 144

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]