Concurrency noob needs strategies not just facts.

I'm a concurrency noob. I've read up on it quite a bit I understand most of it but I've written this program and I'm completely clueless as to how to get my time sensitive data threaded correctly. I've included a vastly oversimplified version just for this post. Look at it like a midi sequencer where, at the same time, you have data being edited via GUI and played back by a clock. Of course, this is a simplification, but in the real version, it sometimes happens that the GUI part of the program can be so taxing that it pushes the timed part out of wack. Can someone point me in the right strategic direction?
This is how the unthreaded program is structured. I tried to make it as close to MVC as possible.
import java.util.*;
public class TryThis {
/*main method simulates the program running*/
     public static void main(String args[]) {
          InfoPlayer myInfoPlayer = new InfoPlayer(); // an object to do time sensitive operations on global data
          InfoEditor myInfoEditor = new InfoEditor(); // an object to send events to edit global data
          InfoDisplayer myInfoDisplayer = new InfoDisplayer(); // an object to display any changes made to global data
          // time sensitive information requested
          myInfoPlayer.string();
          myInfoPlayer.integer();
          // user alters data
          myInfoEditor.setString("joooo");
          myInfoEditor.setInt(11111);
          // time sensitive information requested
          myInfoPlayer.string();
          myInfoPlayer.integer();
          // user alters data
          myInfoEditor.setString("korea");
          myInfoEditor.setInt(3333);
          // time sensitive information requested
          myInfoPlayer.string();
          myInfoPlayer.integer();
/* 1: receives instructions on how to edit info
* 2: edits info
* 3: sends same instructions out as an event to update displays*/
class GlobalReference {
     static private InfoHolder myInfo = new InfoHolder();
     static protected javax.swing.event.EventListenerList listenerList = new javax.swing.event.EventListenerList();
     public static InfoHolder getMyInfo() {
          return myInfo;
     static public void doMyEvent(MyEvent me) {
          if (me.getChangeStringOrInt() == MyEvent.STRING) {
               myInfo.setString(me.getString());
          } else {
               myInfo.setInt(me.getInt());
          fireMyEvent(me);
     static public void addMyEventListener(MyEventListener listener) {
          listenerList.add(MyEventListener.class, listener);
     static void fireMyEvent(MyEvent evt) {
          Object[] listeners = listenerList.getListenerList();
          for (int i = 0; i < listeners.length; i += 2) {
               if (listeners[i] == MyEventListener.class) {
                    ((MyEventListener) listeners[i + 1]).myEventOccurred(evt);
//The info
class InfoHolder {
     String string = "default String";
     int integer = 0;
     public String getString()
          {return string;     }
     public void setString(String myString)
          {this.string = myString;}
     public int getInt()
          {return integer;}
     public void setInt(int myInt)
          {this.integer = myInt;}
//Simulates program displaying data,  listens for updates
class InfoDisplayer implements MyEventListener {
     public InfoDisplayer() {
          GlobalReference.addMyEventListener(this);
     public void myEventOccurred(MyEvent evt) {
          if (evt.getChangeStringOrInt() == MyEvent.STRING) {
               System.out.print("InfoDisplayer:\t\t" + evt.getString() + "\n");
          } else {
               System.out.print("InfoDisplayer:\t\t" + evt.getInt() + "\n");
//simulates user using the UI to edit data
class InfoEditor {
     public void setString(String s) {
          /* event says set global string to source s */
          MyEvent temp = new MyEvent(s, MyEvent.STRING);
          GlobalReference.doMyEvent(temp);
     public void setInt(int i) {
          /* event says set global int to source i */
          MyEvent temp = new MyEvent(i, MyEvent.INT);
          GlobalReference.doMyEvent(temp);
//Simulates calls for time sensitive(read clocked) actions on global data.
class InfoPlayer {
     public void string() {
          System.out.print("InfoPlayer:\t\t"
                    + GlobalReference.getMyInfo().getString() + "\n");
     public void integer() {
          System.out.print("InfoPlayer:\t\t"
                    + GlobalReference.getMyInfo().getInt() + "\n");
/* 1 instructs static info repository on how to edit data,
* 2 then gets send by static repository to update any listeners
class MyEvent extends EventObject {
     static boolean STRING = false, INT = true;
     boolean changeStringOrInt = STRING;
     public MyEvent(Object source, boolean changeStringOrInt) {
          super(source);
          this.changeStringOrInt = changeStringOrInt;
     public String getString()
          {return (String) source;}
     public int getInt()
          {return (Integer) source;}
     public boolean getChangeStringOrInt()
          {return changeStringOrInt;}
/*describes any object that might be used to display global data*/
interface MyEventListener extends EventListener {
     public void myEventOccurred(MyEvent evt);
}Edited by: Mat on May 10, 2009 11:34 PM
Edited by: Mat on May 10, 2009 11:47 PM

Can someone point me in the right strategic direction?That's the only question I can see. It's not much of a question, is it? I suggest you state your problem in more detail. And I don't think the code really helps much at this stage.

Similar Messages

  • After installing the yesterday update for Nightly Firefox 11.0a1 x64(!), i had to reboot my system, could someone pls confirm the reboot was needed and not just me(my system)?

    I ask this cause i never had to reboot my computer after installing an Firefox update, but then again i never used a x64 version before. Thanks.

    10.8.5 is the lates ML edition.  I use TM and also carbon copy cloner as my second backup.  If I were you and you have a TM backup prior to Mavericks I would try another restore at bootup.  You should erase your drive first in that process using disk utitlites and then use TM to put back you apps and files.  The other choice is to do an internet recovery and then use TM to restore your apps and files.  That should fix the permissions issue.  I did the same thing and all was OK including getting my original iPhoto progam (9.4.3), iphoto11 and photos back.

  • I need a new power cord for my Mac book Pro its the T type mag connector. I don't need a Tech just a new cord. How do I buy one. The closest Aplle store is 75 miles away and I do not drive.

    I need a new power cord for my Mac book Pro its the T type mag connector. I don't need a Tech just a new cord. How do I buy one. The closest Aplle store is 75 miles away and I do not drive.

    Are you in the US? Order one from here:  http://store.apple.com/us/browse/home/shop_mac/mac_accessories/power?mco=MTM3NjU xNDg
    Or check out Best Buy.

  • My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need t

    My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need to. It appears as if I selected the entire layer on purpose (which I did not)
    The below items appeared when I opened Photoshop CS 5:
    “Photoshop has encountered a problem with the display driver and has temporarily disabled G & U enhancements. Check the video card malfunctions website for latest software. GPU enhancements can be enabled in the performance panel of preferences.”
    (I believe this started after the automatically updated Windows was applied. It was coincident with the before mentioned problem . . . but I don’t really know if it had anything to do with it. )

    For the Clone Stamp problem, check the Clone Source panel and Clipped is probably unchecked.
    If so, check Clipped and see if that makes a difference.
    (Window>Clone Source)
    As to the video card problem:
    Which version of windows are you using?
    What is the make and model of your graphics card?
    Do you know which update windows installed?

  • The pdfs that are produce in Word are very large. I need a method of compressing them variably - not just a quick reduction using the quartz filter.  Is their a suitable free compression programme,

    The pdfs that I produce in Word are very large. I need a method of compressing them variably - not just a quick reduction using the quartz filter.  Is their a suitable free compression programme,

    PDF Shrink for Mac
    Compress PDF – Reduce your PDF Online
    PdfCompress for Mac

  • I need to plot the Least Squares Regression Line (not just calculate it with the LINEST function).  How?

    I need to plot the Least Squares Regression Line (not just calculate its values with the LINEST function).  Can anyone advise me on how to graph this line?

      Grapher.app in OS X Utilities is excellent for that : entering data from Numbers Excel etc. into a Grapher "Point Set", plotting all your data, computing and plotting a regression curve linear or exponential or polynomial.
      Unfortunately there is not a single word about point sets and regression in the Grapher Help.
    So, suggest you download (free) "Instruction for Use - Grapher on web site
    http://y.barois.free.fr/grapher/Documentation.html
    and go to page 31 to 37, "Initiation > Lesson 6 : Treating a point set (Regression curve), and also page 68, "Appendix 1. Points sets : from speadsheets to Grapher".
      If you try Grapher's regression curves, please tell us about the manual above : useful or not, too easy or difficult, readable or not etc.
      Thank you.
    YB24
    PS. Documentation about Grapher is also here : Google "Apple Grapher" > http://en.wikipedia.org/wiki/Grapher > Article > Talk > Grapher 1.1 to 2.3 (French and English) (11th september 2012)

  • How do you configure the iMac so separate users can access each other's files, especially iPhoto and iTunes? I need to be able to transfer media between two users and not just gain limited access using 'share'.

    How do you configure the iMac so separate users can access each other's files, especially iPhoto and iTunes? I need to be able to transfer media between two users and not just gain limited access using 'share'.

    See Terence Devlin's thorough explanation here.

  • [svn:fx-trunk] 8563: When integrating TLF Build 468, the scrapToPaste() method of PasteOperation needs to be replaced by textScrap.clone(), not just textScrap.

    Revision: 8563
    Author:   [email protected]
    Date:     2009-07-14 14:47:50 -0700 (Tue, 14 Jul 2009)
    Log Message:
    When integrating TLF Build 468, the scrapToPaste() method of PasteOperation needs to be replaced by textScrap.clone(), not just textScrap.
    QE Notes: None
    Doc Notes: None
    Bugs: None
    Reviewer: Carol to review
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/primitives/RichEditableText.as

  • [svn:fx-trunk] 11641: A simple fix - we need to keep track of the display list index for non-clipping masks such as luminosity masks , not just alpha masks.

    Revision: 11641
    Author:   [email protected]
    Date:     2009-11-10 18:29:57 -0800 (Tue, 10 Nov 2009)
    Log Message:
    A simple fix - we need to keep track of the display list index for non-clipping masks such as luminosity masks, not just alpha masks.
    QE notes: Please include tests for multiple graphic content nodes with masks under a .
    Doc notes: N/A
    Bugs:
    SDK-24133 - Multiple non-Group maskees don't work when using maskType="luminosity"
    Reviewer: Deepa
    Tests run: Checkintests, Bug test case
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24133
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java

    Revision: 11641
    Author:   [email protected]
    Date:     2009-11-10 18:29:57 -0800 (Tue, 10 Nov 2009)
    Log Message:
    A simple fix - we need to keep track of the display list index for non-clipping masks such as luminosity masks, not just alpha masks.
    QE notes: Please include tests for multiple graphic content nodes with masks under a .
    Doc notes: N/A
    Bugs:
    SDK-24133 - Multiple non-Group maskees don't work when using maskType="luminosity"
    Reviewer: Deepa
    Tests run: Checkintests, Bug test case
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24133
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java

  • Bought a new monitor.. wide screen 23"... Firefox is not filling the full window. IE works fine but I prefer Firefox. What do I need to do to fill entire window, not just the way it was with the old monitor?

    Bought a new monitor.. wide screen 23"... Firefox is not filling the full window. IE works fine but I prefer Firefox. What do I need to do to fill entire window, not just the way it was with the old monitor? edit

    Most pages are defined to be a certain size, regardless of how large or small your monitor is. You can use Firefox's zoom feature (View menu) to enlarge the text and images (or just the text, if you prefer) on a page.
    In addition to making individual site adjustments, there are some add-ons that will default every site to a higher zoom level. For example, check out:
    * [https://addons.mozilla.org/en-US/firefox/addon/6965/ Default FullZoom Level]
    * [https://addons.mozilla.org/en-US/firefox/addon/2592/ NoSquint]
    Does that help?

  • Need filled form back from user not just data-How?

    I created a static form in LiveCycle.  I want the PDF form back with the data filled in (not just the data) when the user completes the form. How do I do this?

    You need to put a submit button on your form. Then in the submit tab choose the Submit As option to be PDF instead of XDP data file.
    Then you will have to Reader Extend the form to allow for a local save. You can do this in Acrobat under the Advanced/Extend Features in Adobe Reader menu option. Once this is done save the file and distribute the saved version.
    Paul

  • How can I change the margin settings in the pages inspector to make them more specific for label templates. I need margins that can be set to hundreths of a centimetre not just tenths.

    How can I change the margin settings in the pages inspector to make them more specific for label templates. I need margins that can be set to hundreths of a centimetre not just tenths.

    I doubt you need hundreths as you would not even be able to measure that and the printer doesn't hold the paper to those tolerances.
    fruhulda is right. Pages accepts higher measure but rounds it in the measure field.
    If you want absolute accuarcy you need to set your measures to points. Everything else is being recalculated.
    Peter

  • My ipad accidentaly fell with the earpods that i bought separately and unfortunately the right speaker is not working well, sometimes it works, sometimes not. is it covered with 1year warranty? or do i need to pay just to fix it?

    my ipad accidentaly fell with the earpods that i bought separately and unfortunately the right speaker is not working well, sometimes it works, sometimes not. is it covered with 1year warranty? or do i need to pay just to fix it?

    Accidental damage is not covered by any warranty.

  • Noob needs help with Logic and Motu live setup.

    Hello everyone,
    I'm a noob / semi noob who could use some help with a live setup using 2 MOTU 896HD's and Logic on a Mac.
    Here's the scenario:
    I teach an outdoor marching percussion section (a drumline and a front ensemble of marimbas and vibes). We have an amazing setup of live sound to amplify and enhance the mallet percussion. There is a yamaha PA system with 2 subs and 2 mains which are routed through a rack unit that processes the overall PA balance. I'm pretty sure that the unit is supposed to avoid feedback and do an overall cross-over EQ of the sound. Other then that unit, we have 2 motu896hd units which are routed via fire-wire. I also have a coax cable routing the output of the secondary box to the input of the primary box (digital i/o which converts to ADAT in (i think?)..?
    Here's the confusion:
    There are more then 8 inputs being used from the ensemble itself, so I need the 16 available inputs to be available in Logic. I was lead to believe that the 2nd motu unit would have to be sent digitally to the 1st motu unit via coax digital i/o. Once in Logic, however, I cannot find the signal or any input at all past the 8th input (of the 1st unit).
    Here's the goal:
    All of my performers and inputs routed via firewire into a Mac Mini running OSX and Logic pro.
    I want to be able to use MainStage and run different patches of effects / virt. instruments for a midi controller keyboard / etc.
    I want to be able to EQ and balance the ensemble via Logic.
    Here's another question:
    How much latency will I be dealing with? Would a mac mini with 4gb of ram be able to handle this load? With percussion, I obviously want the sound as latency free as possible. I also, however, want the flexibility of sound enhancement / modification that comes with Logic and the motu896hd units.
    Any help would be REALLY appreciated. I need the routing assistance along with some direction as to whether or not this will work for this type of application. I'm pretty certain it does, as I have spoken with some other teachers in similar venues and they have been doing similar things using mac mini's / logic / mainstage / etc.
    Thanks in advance,
    Chris

    You'll definitely want to read the manual to make sure the 896HDs are connected together properly. ADAT is a little tricky, it's not just a matter of cabling them together. Go to motunation.com if you need more guidance on connecting multiple devices. Beyond that initial hookup, here are a couple of quick suggestions:
    1. Open CueMix and see if both devices are reported there. If not, your connections aren't correct. Be sure to select 44.1kHz as your sample rate, otherwise you are reducing the number of additional channels. For instance at 88.2kHz you would get half the additional channels via ADAT.
    2. You may need to create an aggregate device for the MacBook to recognize more than the first 896HD. Lots of help on this forum for how to do that. Again, first make sure you have the 896HDs connected together properly.
    3. As for latency with Mainstage on the Mini, no way to know until you try it. Generally MOTU is fantastic for low latency work but Mainstage is a question mark for a lot of users right now. If the Mini can't cut the mustard, you have a great excuse to upgrade to a MacBook Pro.

  • How can i print all the tab pages not just the first page (tab)

    how can i print all the tab pages not just the first page (tab)

    You would need to do this programmatically. Here's one way:
    Attachments:
    Example_VI_BD6.png ‏3 KB

Maybe you are looking for

  • Cannot get Itunes to open in windows 7 64 bit

    I have installed after a complete reformating of my hard disk, installed and reinstalled itunes several times after a complete unistall of all related programs and tried just about everything that is recommended. What can I do to get itunes to open o

  • My InDesign file keeps failing to export to PDF

    I can't understand why my file won't export as a PDF.  My printer needs my file to be a PDF.

  • When PMON will sense session termination

    Hi All, I don't know what is the correct way to search about my problem, So forgive me if i douplicate my thread with already answered one. I have a scenario where a tool that opens a JBDC connection to the database and when these sessions are killed

  • How td i remove icloud from an old iphone

    i need to remove icloud from a old device

  • Licensing Inquiry for ME-3600x and ME-3800X

    I would like to know how the licensing works for ME-3600X and ME-3800X. For 3600X 1. What is the base license for Cisco ME 3600X-24TS Ethernet Access Switch -ME-3600X-24TS-M? 2. If I want to upgrade the license to Advanced Metro IP Services  using L-