Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod Not Executing in a Synchronous Manner
    primarykey
    data
    text
    <p>I have a MVC-based Java application which I am building, and there is a particular method within my controller (shown below) which behaves as follows:</p> <ul> <li>The model is updated via the initialize method, as I would intend.</li> <li>The update to the view is not occurring because the <code>model.start()</code> method never terminates (since it is an infinite while loop).</li> </ul> <p>I want to have my view to update first, and then be able to <code>start()</code> my model. How do I alter my code to get the desired behavior?</p> <p>I suppose one workaround would be replace the <code>model.start()</code> line with code that fires an event which my model is able to observe, but I have not tried that yet, because I want to understand the source of my problem.</p> <p>Also, I have no idea if this is relevant, but my main application class defines a separate thread for my swing components via <code>SwingUtilities.invokeLater(new Runnable()...</code>, and my view is made up of swing components. There may be some issue related to multiple threads executing, and if so, that would explain why my <code>initializedPerformed()</code> method is not executing in a synchronous way.</p> <p><strong>Method in the controller which does not behave like I expect/want:</strong></p> <pre><code>public void initializePerformed(Event e) { model.initialize(e); view.getPanel().setName(model.getName()); model.start(); } </code></pre> <p><strong>model.start():</strong></p> <pre><code>public void start() { while (true) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload