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: "Nick Emery" <email@hidden>
- Date: Mon, 04 Jun 2001 08:31:11 +0100
- Organization: Peramon technology Ltd
>
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