File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Final Mock Exam question 19 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Final Mock Exam question 19" Watch "Final Mock Exam question 19" New topic
Author

Final Mock Exam question 19

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
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?

What is the case with simple tags?


SCJP, SCWCD, SCBCD
Rufus Addis
Ranch Hand

Joined: Aug 21, 2008
Posts: 83
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.

Simple tags always get new instances!

Rufus.
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

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.

Thanks
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Lot of bugs with HFSJ
Rufus Addis
Ranch Hand

Joined: Aug 21, 2008
Posts: 83
Sadly so Deepak! But to be fair I think there are errors in most technical books!

Rufus.
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
@Rufus
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.


I guess this would not hold true for thread level pooling of classic tags. Please see Restrictions on tag handler reuse in http://www.ibm.com/developerworks/websphere/techjournal/0403_johnson/0403_johnson.html#sec3


Thanks and Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Final Mock Exam question 19