This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Final Mock Exam question 19 I will not type the entire question but will ask the doubt instead Q:Given a classic tag. As we know that Classic tags are re-used which mean they are not instantiated again. Now if two threads invoke the classic tag Will two new instances be created ? as a result the member variables are thread safe?
My understanding is that there will always be a seperate occurance of the Classic Tag handler per thread.
So for example if two threads invoke the classic tag, then there will be two instances of the classic tag handler available, and the member variables will affectively be thread safe.
However these instances of the classic tag handler may be either be new created instances, or re-use existing instances (that are no longer being used). Obviously re-used tags handlers will have member variables in an indetermant state.
SimpleTags are not reused so for every request it will instantiate the class so it is thread safe.There is no concurrency problem here with respect to instance variables, however the static variables will be shared between the request and it will be not thread safe.
Joined: Aug 05, 2006
Lot of bugs with HFSJ
Joined: Aug 21, 2008
Sadly so Deepak! But to be fair I think there are errors in most technical books!