Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Does SWT cocoa need -XstartOnFirstThread ?

Title: Re: [platform-swt-dev] Does SWT cocoa need -XstartOnFirstThread ?
On Carbon, the thread where you initialize the toolbox manager and start up a runloop ‘wins’ and becomes the main thread. On Cocoa, readAndDispatch will ONLY work on Thread 0. Your UI will not work if you don’t.

While I’m glad to hear you got your app working again, if you could get it back to the broken state and file a bug in bugzilla with your stack dump I would appreciate it. The fact that you are using –XstartOnFirstThread and still having UI issues makes me think there’s a bug in Apple’s JVM. I may resolve it as NOT_ECLIPSE, but at least we can see what’s going on.

-- Scott K.

On 5/27/09 5:18 AM, "Ben Staniford" <ben@xxxxxxxxxxxxx> wrote:

Hi Dave,

I've still got -XstartOnFirstThread set and I've had a look at the thread dump already, also I can reproduce in the debugger.  What seems to happen is that the Display.sleep() stops waking up as events arrive and so my application hangs in the readAndDispatch loop.  I've got my application working again but only by altering my main method so that it immediately starts a thread to run my program and then runs readAndDispatch() directly on thread-0.  Not ideal, but it seems to be the only way to get this to work.

Has anyone else had any success running readAndDispatch on any other thread?

Kind Regards,

On Wed, May 27, 2009 at 11:46 AM, Dave Smith <dave.smith@xxxxxxxxxxx> wrote:
did you use the -XStartOnFirstThread? That is still required.... We are using only a SWT app. What we found is that if you had multiple threads loading internal Java libraries they would block...Our case we have the main thread loading the SWT app and  a  background thread loading and configuring the client printers.

Does you app fail or hang? If it hangs, a thread dump should shed some light.



Dave Smith
Candata Systems Ltd.
416-493-9020x2413
Direct: 416-855-2413



On Wed, May 27, 2009 at 4:38 AM, Ben Staniford <ben@xxxxxxxxxxxxx> wrote:
Hmm, that seemed to result in my main window not appearing at all.  Interesting.  It basically caused the readAndDispatch event loop to fail faster than previously so that we hung in sleep() more quickly.  I guess this might have worked for you because you were using a mixed AWT/SWT app?


On Tue, May 26, 2009 at 8:11 PM, Dave Smith <dave.smith@xxxxxxxxxxx> wrote:
We were seeing a similar problem here. In the first line of your code add this ...

java.awt.Toolkit.getDefaultToolkit();

That seemed to fix it for us ..


Dave Smith
Candata Systems Ltd.
416-493-9020x2413
Direct: 416-855-2413




On Tue, May 26, 2009 at 3:00 PM, Ben Staniford <ben@xxxxxxxxxxxxx> wrote:

--===============1925193622718627293==
Content-Type: multipart/alternative; boundary=0016e64715d427b920046ad24e4d

--0016e64715d427b920046ad24e4d
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I've just tried to get the application I work on to run with JDK1.6 and the
64 bit Cocoa SWT library on MacOSX.  However, when I ran it, the GUI just
hung in a horrible half running state.

It looked like previous problems I'd experienced with the Carbon library, to
do with the GUI event loop needing to run on Thread-0.  With the carbon
library it was possible to specify -XstartOnFirstThread to ensure that the
GUI stuff was handled by thread 0, but with the cocoa library that option
doesn't seem to make any difference.

Can anyone give tell me what the right approach should be?  Am I going to
have to refactor my application to make main method start the GUI dispatch
stuff before carrying on with other stuff on a different thread, that would
be a bit horrible given my application design.


--
Ben Staniford
Web:    http://www.staniford.net
Phone:  +44 (0) 151 638 0725
Mobile: +44 (0) 7891 842962

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

I&#39;ve just tried to get the application I work on to run with JDK1.6 and
the 64 bit Cocoa SWT library on MacOSX.=A0 However, when I ran it, the
GUI just hung in a horrible half running state.<br>
<br>
It looked like previous problems I&#39;d experienced with the Carbon
library, to do with the GUI event loop needing to run on Thread-0.=A0
With the carbon library it was possible to specify -XstartOnFirstThread
to ensure that the GUI stuff was handled by thread 0, but with the
cocoa library that option doesn&#39;t seem to make any difference.<br>
<br>
Can anyone give tell me what the right approach should be?=A0 Am I going
to have to refactor my application to make main method start the GUI
dispatch stuff before carrying on with other stuff on a different
thread, that would be a bit horrible given my application design.<br>
<br clear=3D"all"><br>-- <br>Ben Staniford<br>Web: =A0 =A0<a href="" href="http:/=">http:/=
/www.staniford.net <http://www.staniford.net> ">http://www.staniford.net</a><br>Phone: =A0+44 (0) 151 6=
38 0725<br>Mobile: +44 (0) 7891 842962<br>

--0016e64715d427b920046ad24e4d--

--===============1925193622718627293==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

--===============1925193622718627293==--



_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev




Back to the top