<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Explicit multi-threading in Matlab part 1	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=explicit-multi-threading-in-matlab-part1</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Fri, 19 Jun 2020 11:05:54 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Muhammad Muaaz		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-508733</link>

		<dc:creator><![CDATA[Muhammad Muaaz]]></dc:creator>
		<pubDate>Fri, 19 Jun 2020 11:05:54 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-508733</guid>

					<description><![CDATA[Kindly ignore the previous msg, I did not mention the data type while reading the file. It works prefect. Thanks.]]></description>
			<content:encoded><![CDATA[<p>Kindly ignore the previous msg, I did not mention the data type while reading the file. It works prefect. Thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Muhammad Muaaz		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-508732</link>

		<dc:creator><![CDATA[Muhammad Muaaz]]></dc:creator>
		<pubDate>Fri, 19 Jun 2020 11:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-508732</guid>

					<description><![CDATA[Great post!

I use the example you provided on Matlab 2019b, and I am getting similar results on speed. However, I noticed that if we read the file back (no matter if it is written using Matlab, or Java) they both have 40,000,000 elements in them, whereas we have written 50,000,000 elements. Kindly comment, why it is so?]]></description>
			<content:encoded><![CDATA[<p>Great post!</p>
<p>I use the example you provided on Matlab 2019b, and I am getting similar results on speed. However, I noticed that if we read the file back (no matter if it is written using Matlab, or Java) they both have 40,000,000 elements in them, whereas we have written 50,000,000 elements. Kindly comment, why it is so?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peyman		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419205</link>

		<dc:creator><![CDATA[Peyman]]></dc:creator>
		<pubDate>Sun, 18 Feb 2018 20:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-419205</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419168&quot;&gt;Peyman&lt;/a&gt;.

Thanks Yair. Clearing java solved the problem.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419168">Peyman</a>.</p>
<p>Thanks Yair. Clearing java solved the problem.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419185</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 17 Feb 2018 17:05:38 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-419185</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419169&quot;&gt;Peyman&lt;/a&gt;.

@Peyman - it&#039;s probably due to one of the possible reasons that I listed here: http://undocumentedmatlab.com/blog/java-class-access-pitfalls]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419169">Peyman</a>.</p>
<p>@Peyman &#8211; it&#8217;s probably due to one of the possible reasons that I listed here: <a href="http://undocumentedmatlab.com/blog/java-class-access-pitfalls" rel="ugc">http://undocumentedmatlab.com/blog/java-class-access-pitfalls</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peyman		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419169</link>

		<dc:creator><![CDATA[Peyman]]></dc:creator>
		<pubDate>Fri, 16 Feb 2018 23:34:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-419169</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419168&quot;&gt;Peyman&lt;/a&gt;.

Mybe important: I&#039;m using matlab R2008a and jdk 1.6.0 (both matlab and compilation)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419168">Peyman</a>.</p>
<p>Mybe important: I&#8217;m using matlab R2008a and jdk 1.6.0 (both matlab and compilation)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Peyman		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-419168</link>

		<dc:creator><![CDATA[Peyman]]></dc:creator>
		<pubDate>Fri, 16 Feb 2018 23:29:29 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-419168</guid>

					<description><![CDATA[Thank you for the post. It seems to be the exact solution I was looging for but I cannot start the Thread like you showed above. I get the error message: 

&lt;code&gt;??? Undefined function or method &#039;start&#039; for input arguments of type &#039;ParallelPortReaderThread&#039;.
Error in ==&#062; testThread at 8
    start(ParallelPortReaderThread(rr_intervals));&lt;/i&gt;
&lt;/code&gt;

This is my Matlab code:

&lt;pre lang=&quot;matlab&quot;&gt;
import java.lang.Thread;
import java.util.LinkedList;
rr_intervals = LinkedList();
for i = 1:10
    rr_intervals.add(0);
end
javaaddpath &#039;C:\Documents and Settings\user\My Documents\MATLAB\Marieke_Experiment&#039;;
start(ParallelPortReaderThread(rr_intervals));
%ParallelPortReaderThread pThr = new ParallelPortReaderThread(rr_intervals);
%pThr.start();
&lt;/pre&gt;

And this my java class:

&lt;pre lang=&quot;java&quot;&gt;
import java.util.Random;
import java.util.LinkedList;
import java.lang.Thread;
        
public class ParallelPortReaderThread extends Thread {

    private LinkedList rrIntervals;

    public ParallelPortReaderThread(LinkedList queue) {
        this.rrIntervals = queue;
    }

    @Override
    public void run() {
        Random random = new Random();
        long x = (long) (800 + 200 * random.nextFloat());
        rrIntervals.remove();
        rrIntervals.add(x);
	try {
           Thread.sleep(x);
        } catch (InterruptedException ie) {
           ie.printStackTrace();
        }
    }

    public LinkedList getRrIntervals() {
        return rrIntervals;
    }
}
&lt;/pre&gt;

I&#039;d be very thankful about any help and/or advice]]></description>
			<content:encoded><![CDATA[<p>Thank you for the post. It seems to be the exact solution I was looging for but I cannot start the Thread like you showed above. I get the error message: </p>
<p><code>??? Undefined function or method 'start' for input arguments of type 'ParallelPortReaderThread'.<br />
Error in ==&gt; testThread at 8<br />
    start(ParallelPortReaderThread(rr_intervals));<br />
</code></p>
<p>This is my Matlab code:</p>
<pre lang="matlab">
import java.lang.Thread;
import java.util.LinkedList;
rr_intervals = LinkedList();
for i = 1:10
    rr_intervals.add(0);
end
javaaddpath 'C:\Documents and Settings\user\My Documents\MATLAB\Marieke_Experiment';
start(ParallelPortReaderThread(rr_intervals));
%ParallelPortReaderThread pThr = new ParallelPortReaderThread(rr_intervals);
%pThr.start();
</pre>
<p>And this my java class:</p>
<pre lang="java">
import java.util.Random;
import java.util.LinkedList;
import java.lang.Thread;
        
public class ParallelPortReaderThread extends Thread {

    private LinkedList rrIntervals;

    public ParallelPortReaderThread(LinkedList queue) {
        this.rrIntervals = queue;
    }

    @Override
    public void run() {
        Random random = new Random();
        long x = (long) (800 + 200 * random.nextFloat());
        rrIntervals.remove();
        rrIntervals.add(x);
	try {
           Thread.sleep(x);
        } catch (InterruptedException ie) {
           ie.printStackTrace();
        }
    }

    public LinkedList getRrIntervals() {
        return rrIntervals;
    }
}
</pre>
<p>I&#8217;d be very thankful about any help and/or advice</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-418745</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 27 Jan 2018 22:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-418745</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-418742&quot;&gt;Leo&lt;/a&gt;.

@Leo - you can stop a Java thread using its &lt;i&gt;stop()&lt;/i&gt; method:
&lt;pre lang=&quot;matlab&quot;&gt;
jThread = MyJavaThread(&#039;F:\test.data&#039;,data);
start(jThread); % start running in parallel
...
stop(jThread);  % stop thread
&lt;/pre&gt;
&lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;See here&lt;/a&gt; for more details on Java threads.
Of course, if you create your own version of a Java thread, you can create a custom public method that signals the thread in a more elegant manner than the brute-force &lt;i&gt;stop()&lt;/i&gt; method.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-418742">Leo</a>.</p>
<p>@Leo &#8211; you can stop a Java thread using its <i>stop()</i> method:</p>
<pre lang="matlab">
jThread = MyJavaThread('F:\test.data',data);
start(jThread); % start running in parallel
...
stop(jThread);  % stop thread
</pre>
<p><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html" target="_blank" rel="nofollow">See here</a> for more details on Java threads.<br />
Of course, if you create your own version of a Java thread, you can create a custom public method that signals the thread in a more elegant manner than the brute-force <i>stop()</i> method.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Leo		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-418742</link>

		<dc:creator><![CDATA[Leo]]></dc:creator>
		<pubDate>Sat, 27 Jan 2018 18:48:02 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-418742</guid>

					<description><![CDATA[Great post, Yair. I was wondering if it is possible to interrupt the java thread from the matlab main thread, given that the java thread can catch it and exit gracefully. Is there a matlab method available to do it? Thank you very much!]]></description>
			<content:encoded><![CDATA[<p>Great post, Yair. I was wondering if it is possible to interrupt the java thread from the matlab main thread, given that the java thread can catch it and exit gracefully. Is there a matlab method available to do it? Thank you very much!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-409085</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 24 Jun 2017 21:57:24 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-409085</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-409020&quot;&gt;Serge&lt;/a&gt;.

@Serge - you can use a simple Matlab timer for this. Read the documentation for the &lt;i&gt;&lt;b&gt;timer&lt;/b&gt;&lt;/i&gt; function.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-409020">Serge</a>.</p>
<p>@Serge &#8211; you can use a simple Matlab timer for this. Read the documentation for the <i><b>timer</b></i> function.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Serge		</title>
		<link>https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part1#comment-409020</link>

		<dc:creator><![CDATA[Serge]]></dc:creator>
		<pubDate>Fri, 23 Jun 2017 17:26:57 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4659#comment-409020</guid>

					<description><![CDATA[Hello Yair,
I wish to spawn a figure that shows the time while the script continues to run.
I thought figures run in their own thread so I should be able to do this with addlistener, but i am not having luck.
Do i need java? if so can you give any pointers?
Many Thanks,]]></description>
			<content:encoded><![CDATA[<p>Hello Yair,<br />
I wish to spawn a figure that shows the time while the script continues to run.<br />
I thought figures run in their own thread so I should be able to do this with addlistener, but i am not having luck.<br />
Do i need java? if so can you give any pointers?<br />
Many Thanks,</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
