Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » NSThread.isMainThread(isMainThread returns false for main thread)
NSThread.isMainThread [message #630477] Sun, 03 October 2010 06:40 Go to next message
Ozzie is currently offline OzzieFriend
Messages: 1
Registered: July 2009
Junior Member
Hi,

I am an experienced win32 developer but very new to MACOS. I am trying to create a very simple SWT app to learn MACOS and I am stumped at the very start. I have the following code;

public static void main(String[] args) {
    if (NSThread.isMainThread()) {
        System.out.println("BEING MAIN THREAD");
    } else {
        System.out.println("NOT IN MAIN THREAD");
   }
}


This code prints "NOT IN MAIN THREAD". Any ideas why? What am I missing. If I run it in the debugger it's definitely the main (and only) thread.

Thanks for your help
Mark
Re: NSThread.isMainThread [message #630550 is a reply to message #630477] Mon, 04 October 2010 05:06 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 03/10/10 12:10 PM, Ozzie wrote:
> I am an experienced win32 developer but very new to MACOS. I am trying
> to create a very simple SWT app to learn MACOS and I am stumped at the
> very start. I have the following code;
>
>
> public static void main(String[] args) {
> if (NSThread.isMainThread()) {
> System.out.println("BEING MAIN THREAD");
> } else {
> System.out.println("NOT IN MAIN THREAD");
> }
> }
>
>
> This code prints "NOT IN MAIN THREAD". Any ideas why? What am I missing.
> If I run it in the debugger it's definitely the main (and only) thread.

It prints "BEING MAIN THREAD" for me. BTW, if you want to learn MacOS
why are you using SWT? You could try XCode and Cocoa directly

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: NSThread.isMainThread [message #756139 is a reply to message #630550] Fri, 11 November 2011 08:32 Go to previous messageGo to next message
Maksym Bykovskyy is currently offline Maksym BykovskyyFriend
Messages: 3
Registered: July 2010
Junior Member
Answering a question with another question is not a very useful response! I see a similar result. I have an SWT application which runs fine on Windows and Unix but on Mac it complains about Display not being created on the main thread.
Re: NSThread.isMainThread [message #756208 is a reply to message #756139] Fri, 11 November 2011 13:37 Go to previous message
Lakshmi ShanmugamFriend
Messages: 274
Registered: July 2009
Location: India
Senior Member
On Mac, you need to launch the SWT application with the -XstartOnFirstThread VM option.

Lakshmi P Shanmugam
Previous Topic:SWT_AWT, Swing Frame to receive CTRL+C
Next Topic:How to call a section in SWT?
Goto Forum:
  


Current Time: Fri Nov 28 03:40:43 GMT 2014

Powered by FUDForum. Page generated in 0.02108 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software