Featured post
java - ThreadLocal - Is it required if we are setting the value in constructor? -
i have class, mythread implements callable <string>. class has constructor takes parameters blockingqueue , others. in main class, instantiate class, mythread, new blocking queue , other parameters. also, maintain 2 maps, 1 keep mythread reference 1 of unique parameter key , other keep blocking queue reference same unique key.
during process, blocking queue hashmap, add custom message , take corresponding mythread instance , submit threadpooltaskexecutor (spring version).
as far understand, each thread should own copy of values (like blocking queue etc), passing them during construction , creating thread later using threadpooltaskexecutor.submit(mythreadobj). wondering if confirm if true or whether required use threadlocal in scenario. far testing, did not encounter problem, yet load testing.
thanks in advance.
you have reinvented threadlocal. enjoy!
- Get link
- X
- Other Apps
Comments
Post a Comment