[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-user
Subject: RE: Thread-safety question
From: Andy <andrhahn () hotmail ! com>
Date: 2010-12-06 0:01:18
Message-ID: SNT135-w41AC592EDC29D91A7F8C07D92B0 () phx ! gbl
[Download RAW message or body]
Dang. I was hoping XmlObject.Factory.parse() was thread-safe. Maybe a future \
enhancement? Thanks-
From: Pim.Tjeertes@xs4all.nl
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Date: Sun, 5 Dec 2010 22:53:47 +0100
Hi Andy, The method is only thread safe in case you make the either the method or the \
entire class synchronized.Otherwise it’s not thread safe. Well working with just one \
thread would not get you in trouble either of course. ;-) PimFrom: Andy \
[mailto:andrhahn@hotmail.com]
Sent: zondag 5 december 2010 18:14
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question Hi Pim, I I were to leave the method as is, would \
the method not be thread-safe? I ask because this method is part of a library I am \
using. Thanks-From: Pim.Tjeertes@xs4all.nl
To: user@xmlbeans.apache.org
Subject: RE: Thread-safety question
Date: Sun, 5 Dec 2010 15:06:31 +0100Hi Andy, Making your method synchronized should \
take care of thread safety issues. Kind regards,Pim From: Andy \
[mailto:andrhahn@hotmail.com]
Sent: zaterdag 4 december 2010 22:08
To: user@xmlbeans.apache.org
Subject: Thread-safety question Hi, I have a method below that unmarshals an input \
stream and since I will have many concurrent invocations of this method, I was \
wondering if there would be any Thread-safety issues? I'm not a threading expert but \
just wanted to make sure the XmlObject.Factory.parse() method wouldn't cause any \
issues. protected final Object unmarshalInputStream(InputStream inputStream) \
throws XmlMappingException, IOException { try { XmlObject object = \
XmlObject.Factory.parse(inputStream, getXmlOptions()); validate(object); \
return object; } catch (XmlException ex) { throw \
convertXmlBeansException(ex, false); } } Thanks-
[Attachment #3 (text/html)]
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>Dang. I was hoping XmlObject.Factory.parse() was thread-safe. \
Maybe a future enhancement? Thanks-<br><br><hr>From: \
Pim.Tjeertes@xs4all.nl<br>To: user@xmlbeans.apache.org<br>Subject: RE: \
Thread-safety question<br>Date: Sun, 5 Dec 2010 22:53:47 +0100<br><br> \
<meta http-equiv=Content-Type content="text/html; charset=unicode"> <meta \
name=Generator content="Microsoft SafeHTML"><style>
.ExternalClass .ecxshape
{;}
</style><style>
.ExternalClass p.ecxMsoNormal, .ExternalClass li.ecxMsoNormal, .ExternalClass \
div.ecxMsoNormal {margin-bottom:.0001pt;font-size:12.0pt;font-family:'Times New \
Roman','serif';}
.ExternalClass a:link, .ExternalClass span.ecxMsoHyperlink
{color:blue;text-decoration:underline;}
.ExternalClass a:visited, .ExternalClass span.ecxMsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
.ExternalClass p
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:'Times New \
Roman','serif';}
.ExternalClass p.ecxecxmsonormal, .ExternalClass li.ecxecxmsonormal, .ExternalClass \
div.ecxecxmsonormal {margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:'Times \
New Roman','serif';}
.ExternalClass p.ecxecxp1, .ExternalClass li.ecxecxp1, .ExternalClass div.ecxecxp1
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:'Times New \
Roman','serif';}
.ExternalClass p.ecxecxp11, .ExternalClass li.ecxecxp11, .ExternalClass div.ecxecxp11
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:'Times New \
Roman','serif';}
.ExternalClass p.ecxecxmsochpdefault, .ExternalClass li.ecxecxmsochpdefault, \
.ExternalClass div.ecxecxmsochpdefault \
{margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:'Times New \
Roman','serif';}
.ExternalClass span.ecxecxmsohyperlink
{;}
.ExternalClass span.ecxecxmsohyperlinkfollowed
{;}
.ExternalClass span.ecxecxs1
{;}
.ExternalClass span.ecxecxemailstyle21
{;}
.ExternalClass p.ecxecxmsonormal1, .ExternalClass li.ecxecxmsonormal1, .ExternalClass \
div.ecxecxmsonormal1 \
{margin-right:0cm;margin-bottom:0cm;margin-left:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:'Times \
New Roman','serif';}
.ExternalClass span.ecxecxmsohyperlink1
{color:blue;text-decoration:underline;}
.ExternalClass span.ecxecxmsohyperlinkfollowed1
{color:purple;text-decoration:underline;}
.ExternalClass p.ecxecxp12, .ExternalClass li.ecxecxp12, .ExternalClass div.ecxecxp12
{margin-right:0cm;margin-bottom:0cm;margin-left:0cm;margin-bottom:.0001pt;font-size:7.5pt;font-family:Monaco;}
.ExternalClass span.ecxecxs11
{color:#AA0D91;}
.ExternalClass p.ecxecxp111, .ExternalClass li.ecxecxp111, .ExternalClass \
div.ecxecxp111 {margin-right:0cm;margin-bottom:0cm;margin-left:0cm;margin-bottom:.0001pt;font-size:7.5pt;font-family:Monaco;}
.ExternalClass span.ecxecxemailstyle211
{color:#1F497D;}
.ExternalClass p.ecxecxmsochpdefault1, .ExternalClass li.ecxecxmsochpdefault1, \
.ExternalClass div.ecxecxmsochpdefault1 \
{margin-right:0cm;margin-left:0cm;font-size:10.0pt;font-family:'Times New \
Roman','serif';}
.ExternalClass span.ecxEmailStyle34
{color:#1F497D;}
.ExternalClass .ecxMsoChpDefault
{font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;}
.ExternalClass div.ecxWordSection1
{page:WordSection1;}
</style><div class=ecxWordSection1><p class=ecxMsoNormal><span \
style="color:#1F497D">Hi Andy,</span></p><p class=ecxMsoNormal><span \
style="color:#1F497D"> </span></p><p class=ecxMsoNormal><span lang=EN-US \
style="color:#1F497D">The method is only thread safe in case you make the either \
the method or the entire class synchronized.</span></p><p class=ecxMsoNormal><span \
lang=EN-US style="color:#1F497D">Otherwise it’s not thread safe.</span></p><p \
class=ecxMsoNormal><span lang=EN-US style="color:#1F497D"> </span></p><p \
class=ecxMsoNormal><span lang=EN-US style="color:#1F497D">Well working with just \
one thread would not get you in trouble either of course. ;-)</span></p><p \
class=ecxMsoNormal><span lang=EN-US style="color:#1F497D"> </span></p><p \
class=ecxMsoNormal><span lang=EN-US style="color:#1F497D">Pim</span></p><div><div \
style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm \
0cm"><p class=ecxMsoNormal><b><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">From:</span></b><span \
lang=EN-US style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> Andy \
[mailto:andrhahn@hotmail.com] <br><b>Sent:</b> zondag 5 december 2010 \
18:14<br><b>To:</b> user@xmlbeans.apache.org<br><b>Subject:</b> RE: \
Thread-safety question</span></p></div></div><p class=ecxMsoNormal> </p><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Hi \
Pim,</span></p><div><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">I I were to leave \
the method as is, would the method not be thread-safe?</span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">I ask because this \
method is part of a library I am using.</span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p \
class=ecxMsoNormal style="margin-bottom:12.0pt"><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Thanks-</span></p><div \
class=ecxMsoNormal align=center style="text-align:center"><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"><hr size=2 \
width="100%" align=center id=ecxstopSpelling></span></div><p class=ecxMsoNormal \
style="margin-bottom:12.0pt"><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">From: \
Pim.Tjeertes@xs4all.nl<br>To: user@xmlbeans.apache.org<br>Subject: RE: \
Thread-safety question<br>Date: Sun, 5 Dec 2010 15:06:31 \
+0100</span></p><div><p class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D">Hi \
Andy,</span><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><p \
class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D"> </span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><p \
class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D">Making \
your method synchronized should take care of thread safety issues.</span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><p \
class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D"> </span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><p \
class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D">Kind \
regards,</span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><p \
class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D">Pim</span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><p \
class=ecxMsoNormal><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif';color:#1F497D"> </span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><div><div \
style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm \
0cm"><p class=ecxMsoNormal><b><span lang=EN-US \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">From:</span></b><span \
lang=EN-US style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> Andy \
[mailto:andrhahn@hotmail.com] <br><b>Sent:</b> zaterdag 4 december 2010 \
22:08<br><b>To:</b> user@xmlbeans.apache.org<br><b>Subject:</b> \
Thread-safety question</span><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div></div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Hi, I have a \
method below that unmarshals an input stream and since I will have many concurrent \
invocations of this method, I was wondering if there would be any Thread-safety \
issues? I'm not a threading expert but just wanted to make sure the \
XmlObject.Factory.parse() method wouldn't cause any issues.</span></p><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
<span class=ecxs1>protected</span> <span class=ecxs1>final</span> Object \
unmarshalInputStream(InputStream inputStream) <span class=ecxs1>throws</span> \
XmlMappingException, IOException {</span></p><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
<span class=ecxs1>try</span> {</span></p><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
XmlObject object = XmlObject.Factory.parse(inputStream, \
getXmlOptions());</span></p><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
validate(object);</span></p><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
<span class=ecxs1>return</span> object;</span></p><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
}</span></p><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
<span class=ecxs1>catch</span> (XmlException ex) {</span></p><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
<span class=ecxs1>throw</span> \
convertXmlBeansException(ex, <span class=ecxs1>false</span>);</span></p><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
}</span></p><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> \
}</span></p></div><div><p class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p \
class=ecxMsoNormal><span \
style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Thanks-</span></p></div></div></div></div> \
</body> </html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic