Re: Swing Threading in SimpleORM

anthony berglas <[email protected]> Mon, 13 Jun 2011 15:45:36 +1000
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
--90e6ba53a47016e50a04a591708f
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Jun 13, 2011 at 3:45 PM, anthony berglas <[email protected]>wrote:

> I have never liked Swing's over complex threading.
>
> Your solution sounds OK (maybe we should use protected rather than package)
> but I would be concerned that if you end up with more than one swing thread
> active at a time bad things will happen.
>
> One option is to open and close the session on each thread.  The overhead
> is small, and it would be cleaner.
>
> Regards,
>
> Anthony
>
> On Wed, Jun 8, 2011 at 6:05 PM, James Pickering <[email protected]>wrote:
>
>> Hi,
>>
>> I'm having some difficulty getting Swing and SimpleORM to play nice. I've
>> got a workaround, but I'm sure there's a better way.
>>
>> My app uses Swing, and only ever calls SimpleORM from the Swing Event
>> Dispatch Thread. The difficulty is, there's no such thing as "the" Event
>> Dispatch Thread; under some circumstances, Swing recycles it and creates a
>> new one (they're not common circumstances, but I hit them in unit testing).
>> This doesn't sit well with SimpleORM's thread affinity.
>>
>> I've worked around it by creating a subclass of SSessionJdbc, where
>> checkThread() checks it's being run from the EDT, rather than worrying about
>> its preferred thread. With checkThread() being package-private though, it's
>> not an ideal solution.
>>
>> Any thought?
>>
>> Thanks, James
>>
>
>
>
> --
>
> Dr Anthony Berglas, [email protected]       Mobile: +61 4 4838 8874
> Just because it is possible to push twigs along the ground with ones nose
> does not necessarily mean that that is the best way to collect firewood.
>
>


-- 

Dr Anthony Berglas, [email protected]       Mobile: +61 4 4838 8874
Just because it is possible to push twigs along the ground with ones nose
does not necessarily mean that that is the best way to collect firewood.

--90e6ba53a47016e50a04a591708f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable





<head>

<style type=3D"text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title=20
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none;=20
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<html>
<head>
<style type=3D"text/css">
<!--
#ygrp-mkp {
  border: 1px solid #d8d8d8;
  font-family: Arial;
  margin: 10px 0;
  padding: 0 10px;
}

#ygrp-mkp hr {
  border: 1px solid #d8d8d8;
}

#ygrp-mkp #hd {
  color: #628c2a;
  font-size: 85%;
  font-weight: 700;
  line-height: 122%;
  margin: 10px 0;
}

#ygrp-mkp #ads {
  margin-bottom: 10px;
}

#ygrp-mkp .ad {
  padding: 0 0;
}

#ygrp-mkp .ad p {
  margin: 0;
}

#ygrp-mkp .ad a {
  color: #0000ff;
  text-decoration: none;
}
-->
</style>
</head>
<body>





<br><br><div class=3D"gmail_quote">On Mon, Jun 13, 2011 at 3:45 PM, anthony=
 berglas <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]">antho=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div>I have never liked Swing&#39;s over complex threading.</div><div><br><=
/div>Your solution sounds OK (maybe we should use protected rather than pac=
kage) but I would be concerned that if you end up with more than one swing =
thread active at a time bad things will happen.<div>


<br></div><div>One option is to open and close the session on each thread. =
=A0The overhead is small, and it would be cleaner.</div><div><br></div><div=
>Regards,</div><div><br></div><div>Anthony</div><div><div></div><div class=
=3D"h5">

<div><br></div><div class=3D"gmail_quote">
On Wed, Jun 8, 2011 at 6:05 PM, James Pickering <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div style=3D"font-family:sans-serif;font-size:16px">Hi,<br><br>I&#39;=
m having some difficulty getting Swing and SimpleORM to play nice. I&#39;ve=
 got a workaround, but I&#39;m sure there&#39;s a better way.<br><br>My app=
 uses Swing, and only ever calls SimpleORM from the Swing Event Dispatch Th=
read. The difficulty is, there&#39;s no such thing as &quot;the&quot; Event=
 Dispatch Thread; under some circumstances, Swing recycles it and creates a=
 new one (they&#39;re not common circumstances, but I hit them in unit test=
ing). This doesn&#39;t sit well with SimpleORM&#39;s thread affinity.<br>


<br>I&#39;ve worked around it by creating a subclass of SSessionJdbc, where=
 checkThread() checks it&#39;s being run from the EDT, rather than worrying=
 about its preferred thread. With checkThread() being package-private thoug=
h, it&#39;s not an ideal solution.<br>


<br>Any thought?<br><br>Thanks, James</div></div>
</blockquote></div><br><br clear=3D"all"><br></div></div><font color=3D"#88=
8888">-- <br><p>
</p><p>Dr Anthony Berglas, <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a>=A0=A0=A0=A0=A0=A0 Mobile: <a href=3D"tel:%=
2B61%204%204838%208874" value=3D"+61448388874" target=3D"_blank">+61 4 4838=
 8874</a><br>
Just because it is possible to push twigs along the ground with ones nose<b=
r>
does not necessarily mean that that is the best way to collect firewood.</p=
><br>
</font></blockquote></div><br><br clear=3D"all"><br>-- <br><p>
</p><p>Dr Anthony Berglas, <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a>=A0=A0=A0=A0=A0=A0 Mobile: +61 4 4838 8874<=
br>
Just because it is possible to push twigs along the ground with ones nose<b=
r>
does not necessarily mean that that is the best way to collect firewood.</p=
><br>




<!-- |**|begin egp html banner|**| -->

<br>

=20=20=20=20
=20=20=20=20
<br>

<!-- |**|end egp html banner|**| -->


<div width=3D"1" style=3D"color: white; clear: both;"/>__._,_.___</div>

<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src=3D"http://geo.yahoo.com/serv?s=3D97476590/grpId=3D7360226/grpspI=
d=3D1705006905/msgId=3D2031/stime=3D1307943979" width=3D"1" height=3D"1"> <=
br>

<!-- |**|end egp html banner|**| -->

=20=20
<!-- |**|begin egp html banner|**| -->

<br>
      <div style=3D"font-family: verdana; font-size: 77%; border-top: 1px s=
olid #666; padding: 5px 0;" >
      Your email settings: Individual Email|Traditional <br>
      <a href=3D"http://groups.yahoo.com/group/SimpleORM/join;_ylc=3DX3oDMT=
Jmc3Rzc3ByBF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY=
wNmdHIEc2xrA3N0bmdzBHN0aW1lAzEzMDc5NDM5Nzk-">Change settings via the Web</a=
> (Yahoo! ID required) <br>
      Change settings via email: <a href=3D"mailto:SimpleORM-digest@yahoogr=
oups.com?subject=3DEmail Delivery: Digest">Switch delivery to Daily Digest<=
/a> | <a href =3D "mailto:[email protected]?subject=3D=
Change Delivery Format: Fully Featured">Switch to Fully Featured</a> <br>
           <a href=3D"http://groups.yahoo.com/group/SimpleORM;_ylc=3DX3oDMT=
JkbWQyazg2BF9TAzk3NDc2NTkwBGdycElkAzczNjAyMjYEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlY=
wNmdHIEc2xrA2hwZgRzdGltZQMxMzA3OTQzOTc5">
        Visit Your Group=20
      </a> |
      <a href=3D"http://docs.yahoo.com/info/terms/">
        Yahoo! Groups Terms of Use
      </a> |
      <a href=3D"mailto:[email protected]?subject=3DUns=
ubscribe">
       Unsubscribe=20
      </a>=20
 <br>
    </div>
  <br>

<!-- |**|end egp html banner|**| -->


<div style=3D"color: white; clear: both;"/>__,_._,___</div>
</body>

</html>

--90e6ba53a47016e50a04a591708f--