Re: java cocoa appkit application and multiple threads
Re: java cocoa appkit application and multiple threads
- Subject: Re: java cocoa appkit application and multiple threads
- From: Michael Dupuis <email@hidden>
- Date: Mon, 25 Jun 2001 23:19:32 -0400
Hi Nikki, I kind of got sidetracked from this thread on the cocoa-dev list a
while back. I do indeed have some threading issues of the same nature you
were having. I think your solution seems to make the most sense, as far as
thread safety goes.
A couple of questions since you've gotten it to work, if you'd permit me.
Did you wind up creating a new NSEvent and handing that event in a NSWindow
subclass? I seem to be having a problem getting my subclass to display
correctly. If I don't define any of the NSWindow constructors in my
subclass, than my window never appears. If my subclass implements the
NSWindow constructors, then I get a frameless window. It appears as though
the window has a mask of BorderlessWindowMask. I haven't tried to subclass
any of the Cocoa objects yet, so I'm not sure what's going on. I'm not doing
anything in my constructors other than passing the values to super(). Any
ideas? I can't find anything that explicitly says how to subclass an
NSWindow, so I'm obviously doing it wrong and forgetting something.
Also when you created your NSEvent, did you create it like this?
NSEvent.otherEvent(NSEvent.ApplicationDefined,
new NSPoint(0,0), 0, 0.0,
owner.window().windowNumber(), null, THREAD_ID,
-1, -1);
or something like this? I wasn't able to find a way to get a value for time,
which is supposed to be the time since startup.
Thanks or any help,
Michael
>
From: email@hidden
>
Reply-To: email@hidden
>
Date: Mon, 4 Jun 2001 11:17:12 -0700 (PDT)
>
To: email@hidden
>
Subject: cocoa-dev digest, Vol 1 #97 - 14 msgs
>
>
To: email@hidden
>
Subject: Re: java cocoa appkit application and multiple threads
>
From: "Nick Emery" <email@hidden>
>
Organization: Peramon technology Ltd
>
Date: Mon, 04 Jun 2001 08:31:11 +0100
>
>
> In what I'm doing, I build the entire data set in the thread. I then set the
>
> contents of the data storage object that I am using for my table, that way
>
> there are no synchronization issues like you are seeing. The only problem is
>
> that until the thread completes, the user isn't able to view any of the
>
data.
>
>
michael,
>
>
i think you still have the same problem that is present in my code. the
>
problem is that the appkit makes independent, unsynchronized calls to
>
NSTableView.DataSource's numberOfRowsInTableView and
>
tableViewObjectValueForLocation. if the worker thread sets the data source's
>
datset between these two calls, then it is possible for the appkit to call
>
tableViewObjectValueForLocation for a row that does not exist in the new
>
dataset. i guess you could program defensively to cover this outcome, but it
>
does indicate that the appkit is not designed to be thread safe (as supported
>
by the documentation).
>
>
i have now found a reliable way to signal that the worker thread has completed
>
its work in the main thread: i post a appDefined event. this is very messy,
>
however, because these events get mixed up with the ui (mouse and keyboard)
>
events. i really think that there should be a cleaner way for a worker thread
>
to signal completion of a task in the main appkit thread.
>
>
--nikki