Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM cost reform

...

The following table shows a possible execution order:

Time

Task

Pool Thread

Submitted by Method

Day

1

t1

1

doSomething1()

Friday

2

t2

2

doSomething2()

Monday

3

t3

1

doSomething2()

Friday

In this execution order, it is expected that the two tasks (t2 and t3) started from doSomething2() would observe the current day as Monday. However, because pool thread 1 is reused, t3 observes the day to be Friday.

...

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

Rule

Severity

Likelihood

Remediation Cost

Detectable

Repairable

Priority

Level

TPS04-J

Medium

Probable

Yes

High

No

P4

P8

L3

L2

Bibliography

[API 2014]

Class java.lang.ThreadLocal<T>

[JPL 2006]

Section 14.13, "ThreadLocal Variables"

...


...