• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: GUI update, multi-threaded Cocoa Java app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI update, multi-threaded Cocoa Java app


  • Subject: Re: GUI update, multi-threaded Cocoa Java app
  • From: Cryx <email@hidden>
  • Date: Mon, 22 Apr 2002 21:31:59 -0500

You will need to use a distributed notification center for inter-thread notifications. The caveat is that only NSString objects can be posted. See NSCoder/NSArchiver for details on how to hopefully work around this issue. It seems that obj-c has more options than java, but it appears to be feasible in java.

If that proves to be too much effort, a producer/consumer model could post notifications to the main thread after pushing objects onto an array. The main thread would use the notification to consume. Just be sure to lock the array.

On Monday, April 22, 2002, at 02:39 AM, John W. Whitworth wrote:

What is the accepted wisdom on updating a Cocoa Java GUI from Java threads producing data?

No distributed objects in Cocoa Java.
Selectors invoked by notifications don't run in the main run loop but in the threads sending the notification.
I tried passing a reference to the main run loop to the threads so that they could schedule a selector call (performSelectorWithOrder) but this didn't work.

All I could come up with was a repeating timer updating the GUI in the main run loop from data posted from the threads via synchronized methods.

I guess some kind of producer/consumer synchronization might be possible between the main and spawned threads. There must be an elegant solution, such as the swing invokelater call.

John Whitworth
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >GUI update, multi-threaded Cocoa Java app (From: "John W. Whitworth" <email@hidden>)

  • Prev by Date: NSOpenGLView Subclass
  • Next by Date: Re: NSOpenGLView Subclass
  • Previous by thread: GUI update, multi-threaded Cocoa Java app
  • Next by thread: Being informed when the window moves
  • Index(es):
    • Date
    • Thread