<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FThreads%2FTemplate</id>
		<title>Java/Threads/Template - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FThreads%2FTemplate"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Threads/Template&amp;action=history"/>
		<updated>2026-06-07T16:26:36Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Threads/Template&amp;diff=8321&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Threads/Template&amp;diff=8321&amp;oldid=prev"/>
				<updated>2010-06-01T06:58:56Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:58, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Threads/Template&amp;diff=8320&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Threads/Template&amp;diff=8320&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Inner self run threads ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class InnerSelfRunMain extends Object {&lt;br /&gt;
  private Thread internalThread;&lt;br /&gt;
  private volatile boolean noStopRequested;&lt;br /&gt;
  public InnerSelfRunMain() {&lt;br /&gt;
    // add your code here ...&lt;br /&gt;
    System.out.println(&amp;quot;initializing...&amp;quot;);&lt;br /&gt;
    noStopRequested = true;&lt;br /&gt;
    Runnable r = new Runnable() {&lt;br /&gt;
      public void run() {&lt;br /&gt;
        try {&lt;br /&gt;
          runWork();&lt;br /&gt;
        } catch (Exception x) {&lt;br /&gt;
          // in case ANY exception slips through&lt;br /&gt;
          x.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    internalThread = new Thread(r);&lt;br /&gt;
    internalThread.start();&lt;br /&gt;
  }&lt;br /&gt;
  private void runWork() {&lt;br /&gt;
    while (noStopRequested) {&lt;br /&gt;
      System.out.println(&amp;quot;in runWork() - still going...&amp;quot;);&lt;br /&gt;
      try {&lt;br /&gt;
        Thread.sleep(700);&lt;br /&gt;
      } catch (InterruptedException x) {&lt;br /&gt;
        Thread.currentThread().interrupt(); // re-assert interrupt&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void stopRequest() {&lt;br /&gt;
    noStopRequested = false;&lt;br /&gt;
    internalThread.interrupt();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isAlive() {&lt;br /&gt;
    return internalThread.isAlive();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    InnerSelfRunMain sr = new InnerSelfRunMain();&lt;br /&gt;
    try {&lt;br /&gt;
      Thread.sleep(3000);&lt;br /&gt;
    } catch (InterruptedException x) {&lt;br /&gt;
    }&lt;br /&gt;
    sr.stopRequest();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Self run thread ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class SelfRunThreadTemplate extends Object implements Runnable {&lt;br /&gt;
  private Thread internalThread;&lt;br /&gt;
  private volatile boolean noStopRequested;&lt;br /&gt;
  public SelfRunThreadTemplate() {&lt;br /&gt;
    // add your code here ...&lt;br /&gt;
    System.out.println(&amp;quot;initializing...&amp;quot;);&lt;br /&gt;
    noStopRequested = true;&lt;br /&gt;
    internalThread = new Thread(this);&lt;br /&gt;
    internalThread.start();&lt;br /&gt;
  }&lt;br /&gt;
  public void run() {&lt;br /&gt;
    if ( Thread.currentThread() != internalThread ) {&lt;br /&gt;
      throw new RuntimeException(&amp;quot;only the internal &amp;quot; +&lt;br /&gt;
        &amp;quot;thread is allowed to invoke run()&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    while ( noStopRequested ) {&lt;br /&gt;
      System.out.println(&amp;quot;in run() - still going...&amp;quot;);&lt;br /&gt;
      try {&lt;br /&gt;
        Thread.sleep(700);&lt;br /&gt;
      } catch ( InterruptedException x ) {&lt;br /&gt;
        Thread.currentThread().interrupt(); &lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void stopRequest() {&lt;br /&gt;
    noStopRequested = false;&lt;br /&gt;
    internalThread.interrupt();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isAlive() {&lt;br /&gt;
    return internalThread.isAlive();&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    SelfRunThreadTemplate sr = new SelfRunThreadTemplate();&lt;br /&gt;
    try { Thread.sleep(3000); } catch ( InterruptedException x ) { }&lt;br /&gt;
    sr.stopRequest();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>