<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.byte-welt.net/index.php?action=history&amp;feed=atom&amp;title=ProgressBars%2C_Algorithmen_und_Multithreading</id>
	<title>ProgressBars, Algorithmen und Multithreading - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.byte-welt.net/index.php?action=history&amp;feed=atom&amp;title=ProgressBars%2C_Algorithmen_und_Multithreading"/>
	<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;action=history"/>
	<updated>2026-08-11T04:31:12Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Byte-Welt Wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=8652&amp;oldid=prev</id>
		<title>L-ectron-X am 22. Dezember 2018 um 10:57 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=8652&amp;oldid=prev"/>
		<updated>2018-12-22T10:57:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 22. Dezember 2018, 10:57 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l299&quot;&gt;Zeile 299:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 299:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche &amp;lt;code&amp;gt;dialog.setVisible(true)&amp;lt;/code&amp;gt; aufgerufen hat.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche &amp;lt;code&amp;gt;dialog.setVisible(true)&amp;lt;/code&amp;gt; aufgerufen hat.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:Tutorials &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(Java)&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:Swing]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:Swing]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Beni|Beni]] (01.09.2004, 01:56)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Beni|Beni]] (01.09.2004, 01:56)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Bleiglanz|Bleiglanz]] (01.09.2004)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Bleiglanz|Bleiglanz]] (01.09.2004)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>L-ectron-X</name></author>
	</entry>
	<entry>
		<id>https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=8650&amp;oldid=prev</id>
		<title>L-ectron-X am 22. Dezember 2018 um 10:55 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=8650&amp;oldid=prev"/>
		<updated>2018-12-22T10:55:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 22. Dezember 2018, 10:55 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Zeile 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Für die &amp;lt;code&amp;gt;run()&amp;lt;/code&amp;gt;-Methode des Runnables gilt dasselbe wie für alle anderen Methoden, die im EventDispatcher ausgeführt werden: sie muss schnell abgearbeitet werden, denn sonst friert die Oberfläche ein.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Für die &amp;lt;code&amp;gt;run()&amp;lt;/code&amp;gt;-Methode des Runnables gilt dasselbe wie für alle anderen Methoden, die im EventDispatcher ausgeführt werden: sie muss schnell abgearbeitet werden, denn sonst friert die Oberfläche ein.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Übrigens: &amp;lt;code&amp;gt;invokeAndWait()&amp;lt;/code&amp;gt; sollte man auf keinen Fall in einer Methode wie &amp;lt;code&amp;gt;actionPerformed()&amp;lt;/code&amp;gt; (oder jede andere Methode, die vom EventDispatcher aufgerufen wird) benutzen. Das Resultat ist stets eine [[Exception]], oder noch schlimmer, ein eingefrorenes Programm.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Übrigens: &amp;lt;code&amp;gt;invokeAndWait()&amp;lt;/code&amp;gt; sollte man auf keinen Fall in einer Methode wie &amp;lt;code&amp;gt;actionPerformed()&amp;lt;/code&amp;gt; (oder jede andere Methode, die vom EventDispatcher aufgerufen wird) benutzen. Das Resultat ist stets eine [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Was ist eine Exception?|&lt;/ins&gt;Exception]], oder noch schlimmer, ein eingefrorenes Programm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Es sei auch auf die Möglichkeit der Verwendung eines {{JAPI|ProgressMonitors}} hingewiesen, welcher das Implementieren eines Frames/Dialoges mit dem Fortschrittsbalken überflüssig macht&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Es sei auch auf die Möglichkeit der Verwendung eines {{JAPI|ProgressMonitors}} hingewiesen, welcher das Implementieren eines Frames/Dialoges mit dem Fortschrittsbalken überflüssig macht&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>L-ectron-X</name></author>
	</entry>
	<entry>
		<id>https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=8649&amp;oldid=prev</id>
		<title>L-ectron-X am 22. Dezember 2018 um 10:53 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=8649&amp;oldid=prev"/>
		<updated>2018-12-22T10:53:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 22. Dezember 2018, 10:53 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Manchmal schreibt man eine Methode, die &quot;etwas mehr Zeit&quot; benötigt. Wenn eine Methode länger als 3 Sekunden das Programm blockiert, ist ein Fortschrittsbalken eine gute Idee, den User bei Laune zu halten.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Manchmal schreibt man eine &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;Methode&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/ins&gt;, die &quot;etwas mehr Zeit&quot; benötigt. Wenn eine Methode länger als 3 Sekunden das Programm blockiert, ist ein Fortschrittsbalken eine gute Idee, den User bei Laune zu halten.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(Die menschliche Aufmerksamkeitsspanne ist etwa 3 Sekunden. Was länger als 3 Sekunden still steht, wird als unbeweglich wahrgenommen. Im Falle eines Programmes bedeutet dies: &amp;quot;Das Programm ist voll schlecht, das arbeitet ja gar nicht!&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(Die menschliche Aufmerksamkeitsspanne ist etwa 3 Sekunden. Was länger als 3 Sekunden still steht, wird als unbeweglich wahrgenommen. Im Falle eines Programmes bedeutet dies: &amp;quot;Das Programm ist voll schlecht, das arbeitet ja gar nicht!&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Mit einem Fortschrittsbalken lenkt man den Benutzer ab. Der Algorithmus der ausgeführt wird, ist dadurch nicht schneller, im Gegenteil, der Fortschrittsbalken benötigt zusätzliche Rechenzeit. Objektiv verlangsamt man also das Programm, aber subjektiv wird es schneller. Und Menschen sind nun einmal grausam subjektive Wesen...)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Mit einem Fortschrittsbalken lenkt man den Benutzer ab. Der Algorithmus der ausgeführt wird, ist dadurch nicht schneller, im Gegenteil, der Fortschrittsbalken benötigt zusätzliche Rechenzeit. Objektiv verlangsamt man also das Programm, aber subjektiv wird es schneller. Und Menschen sind nun einmal grausam subjektive Wesen...)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Für den Fortschrittsbalken wird die Komponente JProgressBar verwendet. Der Algorithmus wird in mehr oder weniger regelmäßigen Abständen den Wert (value) des Balkens verändern.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Für den Fortschrittsbalken wird die Komponente &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{JAPI|&lt;/ins&gt;JProgressBar&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}} &lt;/ins&gt;verwendet. Der &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;Algorithmus&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;wird in mehr oder weniger regelmäßigen Abständen den Wert (value) des Balkens verändern.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Es stellt sich nun das Problem, dass gleichzeitig ein Algorithmus ablaufen, und ein Fortschittsbalken gezeichnet werden soll.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Es stellt sich nun das Problem, dass gleichzeitig ein Algorithmus ablaufen, und ein Fortschittsbalken gezeichnet werden soll.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l12&quot;&gt;Zeile 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Und da Swing nicht threadsicher ist, darf man von dem ausgelagerten Algorithmus eigentlich nicht auf den Fortschrittsbalken zugreifen.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Und da Swing nicht threadsicher ist, darf man von dem ausgelagerten Algorithmus eigentlich nicht auf den Fortschrittsbalken zugreifen.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Glücklicherweise haben die Swing-Programmierer, extra um dieses Problem zu lösen, die Methoden SwingUtilities.invokeLater() und SwingUtilities.invokeAndWait() geschrieben. Diese Methoden nehmen eine Instanz eines Runnable&#039;s auf, und speichern es vorerst. Zu einem späteren Zeitpunkt wird der EventDispatcher-Thread (der Thread, der die graphische Oberfläche zeichnet und Events herumschickt) dieses Runnable nehmen und die Methode run() ausführen.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Glücklicherweise haben die Swing-Programmierer, extra um dieses Problem zu lösen, die Methoden &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;SwingUtilities.invokeLater()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;und &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;SwingUtilities.invokeAndWait()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;geschrieben. Diese Methoden nehmen eine &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;Instanz&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;eines Runnable&#039;s auf, und speichern es vorerst. Zu einem späteren Zeitpunkt wird der EventDispatcher-Thread (der &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;Thread&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/ins&gt;, der die graphische Oberfläche zeichnet und Events herumschickt) dieses &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{JAPI|&lt;/ins&gt;Runnable&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}} &lt;/ins&gt;nehmen und die Methode &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;run()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;ausführen.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/del&gt;Der Unterschied zwischen invokeLater() und invokeAndWait()&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===&lt;/ins&gt;Der Unterschied zwischen invokeLater() und invokeAndWait()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Bei einem Aufruf von invokeLater() kann der aufrufende Thread sofort weiterarbeiten. Bei einem Aufruf von invokeAndWait() wartet der aufrufende Thread bis das Runnable abgearbeitet wurde. invokeAndWait() verhält sich also ganz ähnlich, als würde man einen gigantischen synchronized-Block über die GUI legen und in diesem Block irgendwas berechnen.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Bei einem Aufruf von &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;invokeLater()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;kann der aufrufende Thread sofort weiterarbeiten. Bei einem Aufruf von &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;invokeAndWait()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;wartet der aufrufende Thread bis das Runnable abgearbeitet wurde. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;invokeAndWait()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;verhält sich also ganz ähnlich, als würde man einen gigantischen synchronized-Block über die &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;GUI&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;legen und in diesem Block irgendwas berechnen.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Für die run()-Methode des Runnables gilt dasselbe wie für alle anderen Methoden, die im EventDispatcher ausgeführt werden: sie muss schnell abgearbeitet werden, denn sonst friert die Oberfläche ein.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Für die &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;run()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;-Methode des Runnables gilt dasselbe wie für alle anderen Methoden, die im EventDispatcher ausgeführt werden: sie muss schnell abgearbeitet werden, denn sonst friert die Oberfläche ein.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Übrigens: invokeAndWait() sollte man auf keinen Fall in einer Methode wie actionPerformed() (oder jede andere Methode, die vom EventDispatcher aufgerufen wird) benutzen. Das Resultat ist stets eine Exception, oder noch schlimmer, ein eingefrorenes Programm.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Übrigens: &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;invokeAndWait()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;sollte man auf keinen Fall in einer Methode wie &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;actionPerformed()&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;(oder jede andere Methode, die vom EventDispatcher aufgerufen wird) benutzen. Das Resultat ist stets eine &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;Exception&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/ins&gt;, oder noch schlimmer, ein eingefrorenes Programm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Es sei auch auf die Möglichkeit der Verwendung eines ProgressMonitors hingewiesen, welcher das Implementieren eines Frames/Dialoges mit dem Fortschrittsbalken überflüssig macht.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/ins&gt;Es sei auch auf die Möglichkeit der Verwendung eines &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{JAPI|&lt;/ins&gt;ProgressMonitors&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}} &lt;/ins&gt;hingewiesen, welcher das Implementieren eines Frames/Dialoges mit dem Fortschrittsbalken überflüssig macht&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Das folgende Beispiel zeigt ein Fenster, auf dem ein Fortschrittsbalken und zwei Knöpfe sind. Mit dem einen - start - wird ein Algorithmus gestartet, der Fortschrittsbalken beginnt zu wandern. Mit dem zweiten - stop - wird der Algorithmus abgebrochen, alles kehrt wieder zum Anfangszustand zurück (Den Stop-Button könnte man auch in einen Pause-Button umwandeln ).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Das folgende Beispiel zeigt ein Fenster, auf dem ein Fortschrittsbalken und zwei &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[JButton|&lt;/ins&gt;Knöpfe&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;sind. Mit dem einen - start - wird ein Algorithmus gestartet, der Fortschrittsbalken beginnt zu wandern. Mit dem zweiten - stop - wird der Algorithmus abgebrochen, alles kehrt wieder zum Anfangszustand zurück (Den Stop-Button könnte man auch in einen Pause-Button umwandeln ).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l296&quot;&gt;Zeile 296:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 297:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche dialog.setVisible(true) aufgerufen hat.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;dialog.setVisible(true)&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;aufgerufen hat.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Java&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Tutorials&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:Swing]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Kategorie:Swing]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Beni|Beni]] (01.09.2004, 01:56)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Beni|Beni]] (01.09.2004, 01:56)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Bleiglanz|Bleiglanz]] (01.09.2004)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--[[Benutzer:Bleiglanz|Bleiglanz]] (01.09.2004)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>L-ectron-X</name></author>
	</entry>
	<entry>
		<id>https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=7764&amp;oldid=prev</id>
		<title>L-ectron-X am 15. März 2018 um 18:54 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=7764&amp;oldid=prev"/>
		<updated>2018-03-15T18:54:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 15. März 2018, 18:54 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l24&quot;&gt;Zeile 24:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 24:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Das folgende Beispiel zeigt ein Fenster, auf dem ein Fortschrittsbalken und zwei Knöpfe sind. Mit dem einen - start - wird ein Algorithmus gestartet, der Fortschrittsbalken beginnt zu wandern. Mit dem zweiten - stop - wird der Algorithmus abgebrochen, alles kehrt wieder zum Anfangszustand zurück (Den Stop-Button könnte man auch in einen Pause-Button umwandeln ).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Das folgende Beispiel zeigt ein Fenster, auf dem ein Fortschrittsbalken und zwei Knöpfe sind. Mit dem einen - start - wird ein Algorithmus gestartet, der Fortschrittsbalken beginnt zu wandern. Mit dem zweiten - stop - wird der Algorithmus abgebrochen, alles kehrt wieder zum Anfangszustand zurück (Den Stop-Button könnte man auch in einen Pause-Button umwandeln ).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code&lt;/del&gt;=java&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight lang&lt;/ins&gt;=&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/ins&gt;java&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import java.awt.Container;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import java.awt.Container;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import java.awt.GridBagConstraints;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import java.awt.GridBagConstraints;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l178&quot;&gt;Zeile 178:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 178:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code=java&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code&lt;/del&gt;=java&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight lang&lt;/ins&gt;=&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/ins&gt;java&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import javax.swing.JProgressBar;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import javax.swing.JProgressBar;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import javax.swing.SwingUtilities;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import javax.swing.SwingUtilities;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l294&quot;&gt;Zeile 294:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 294:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code=java&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche dialog.setVisible(true) aufgerufen hat.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche dialog.setVisible(true) aufgerufen hat.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>L-ectron-X</name></author>
	</entry>
	<entry>
		<id>https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=5919&amp;oldid=prev</id>
		<title>L-ectron-x: Die Seite wurde neu angelegt: „Manchmal schreibt man eine Methode, die &quot;etwas mehr Zeit&quot; benötigt. Wenn eine Methode länger als 3 Sekunden das Programm blockiert, ist ein Fortschrittsbalken e…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.byte-welt.net/index.php?title=ProgressBars,_Algorithmen_und_Multithreading&amp;diff=5919&amp;oldid=prev"/>
		<updated>2013-11-10T09:59:12Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „Manchmal schreibt man eine Methode, die &amp;quot;etwas mehr Zeit&amp;quot; benötigt. Wenn eine Methode länger als 3 Sekunden das Programm blockiert, ist ein Fortschrittsbalken e…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Manchmal schreibt man eine Methode, die &amp;quot;etwas mehr Zeit&amp;quot; benötigt. Wenn eine Methode länger als 3 Sekunden das Programm blockiert, ist ein Fortschrittsbalken eine gute Idee, den User bei Laune zu halten.&lt;br /&gt;
&lt;br /&gt;
(Die menschliche Aufmerksamkeitsspanne ist etwa 3 Sekunden. Was länger als 3 Sekunden still steht, wird als unbeweglich wahrgenommen. Im Falle eines Programmes bedeutet dies: &amp;quot;Das Programm ist voll schlecht, das arbeitet ja gar nicht!&amp;quot;&lt;br /&gt;
Mit einem Fortschrittsbalken lenkt man den Benutzer ab. Der Algorithmus der ausgeführt wird, ist dadurch nicht schneller, im Gegenteil, der Fortschrittsbalken benötigt zusätzliche Rechenzeit. Objektiv verlangsamt man also das Programm, aber subjektiv wird es schneller. Und Menschen sind nun einmal grausam subjektive Wesen...)&lt;br /&gt;
&lt;br /&gt;
Für den Fortschrittsbalken wird die Komponente JProgressBar verwendet. Der Algorithmus wird in mehr oder weniger regelmäßigen Abständen den Wert (value) des Balkens verändern.&lt;br /&gt;
&lt;br /&gt;
Es stellt sich nun das Problem, dass gleichzeitig ein Algorithmus ablaufen, und ein Fortschittsbalken gezeichnet werden soll.&lt;br /&gt;
Man kann dies mit Multithreading, also dem Aufteilen des Programmes in mehrere Prozesse, erreichen.&lt;br /&gt;
&lt;br /&gt;
Da der Aufbau von Swing (bzw. AWT) es nicht erlaubt, Teile der graphischen Oberfläche in einen anderen Thread auszulagern, muss man in jedem Fall den Algorithmus auslagern.&lt;br /&gt;
Und da Swing nicht threadsicher ist, darf man von dem ausgelagerten Algorithmus eigentlich nicht auf den Fortschrittsbalken zugreifen.&lt;br /&gt;
&lt;br /&gt;
Glücklicherweise haben die Swing-Programmierer, extra um dieses Problem zu lösen, die Methoden SwingUtilities.invokeLater() und SwingUtilities.invokeAndWait() geschrieben. Diese Methoden nehmen eine Instanz eines Runnable&amp;#039;s auf, und speichern es vorerst. Zu einem späteren Zeitpunkt wird der EventDispatcher-Thread (der Thread, der die graphische Oberfläche zeichnet und Events herumschickt) dieses Runnable nehmen und die Methode run() ausführen.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Der Unterschied zwischen invokeLater() und invokeAndWait()&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Bei einem Aufruf von invokeLater() kann der aufrufende Thread sofort weiterarbeiten. Bei einem Aufruf von invokeAndWait() wartet der aufrufende Thread bis das Runnable abgearbeitet wurde. invokeAndWait() verhält sich also ganz ähnlich, als würde man einen gigantischen synchronized-Block über die GUI legen und in diesem Block irgendwas berechnen.&lt;br /&gt;
Für die run()-Methode des Runnables gilt dasselbe wie für alle anderen Methoden, die im EventDispatcher ausgeführt werden: sie muss schnell abgearbeitet werden, denn sonst friert die Oberfläche ein.&lt;br /&gt;
&lt;br /&gt;
Übrigens: invokeAndWait() sollte man auf keinen Fall in einer Methode wie actionPerformed() (oder jede andere Methode, die vom EventDispatcher aufgerufen wird) benutzen. Das Resultat ist stets eine Exception, oder noch schlimmer, ein eingefrorenes Programm.&lt;br /&gt;
&lt;br /&gt;
Es sei auch auf die Möglichkeit der Verwendung eines ProgressMonitors hingewiesen, welcher das Implementieren eines Frames/Dialoges mit dem Fortschrittsbalken überflüssig macht.&lt;br /&gt;
&lt;br /&gt;
Das folgende Beispiel zeigt ein Fenster, auf dem ein Fortschrittsbalken und zwei Knöpfe sind. Mit dem einen - start - wird ein Algorithmus gestartet, der Fortschrittsbalken beginnt zu wandern. Mit dem zweiten - stop - wird der Algorithmus abgebrochen, alles kehrt wieder zum Anfangszustand zurück (Den Stop-Button könnte man auch in einen Pause-Button umwandeln ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code=java&amp;gt;&lt;br /&gt;
import java.awt.Container;&lt;br /&gt;
import java.awt.GridBagConstraints;&lt;br /&gt;
import java.awt.GridBagLayout;&lt;br /&gt;
import java.awt.GridLayout;&lt;br /&gt;
import java.awt.Insets;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JOptionPane;&lt;br /&gt;
import javax.swing.JPanel;&lt;br /&gt;
import javax.swing.JProgressBar;&lt;br /&gt;
import javax.swing.SwingUtilities;&lt;br /&gt;
/**&lt;br /&gt;
 * Ein hübsches Fenster mit einem Fortschrittsbalken und zwei Knöpfen &amp;quot;start&amp;quot;&lt;br /&gt;
 * und &amp;quot;stop&amp;quot;.&lt;br /&gt;
 */&lt;br /&gt;
public class Main extends JFrame implements Runnable{   &lt;br /&gt;
    /** Der Algorithmus, der ausgeführt werden soll */&lt;br /&gt;
    private Algorithmus algorithmus;&lt;br /&gt;
    /** Der Fortschrittsbalken */&lt;br /&gt;
    private JProgressBar progress;&lt;br /&gt;
    /** Verschiedene Knöpfe um den Algorithmus zu steuern */&lt;br /&gt;
    private JButton buttonStart, buttonStop;&lt;br /&gt;
    /**&lt;br /&gt;
     * Irgendwo muss das Programm ja starten...&lt;br /&gt;
     * @param args Zusätzliche Argumente, dieser Wert wird zurzeit nicht benötigt&lt;br /&gt;
     */&lt;br /&gt;
    public static void main( String[] args ){&lt;br /&gt;
        Main main = new Main();&lt;br /&gt;
        main.setVisible( true );&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Standartkonstruktor, stellt ein neues Fenster her.&lt;br /&gt;
     */&lt;br /&gt;
    public Main(){&lt;br /&gt;
        setTitle( &amp;quot;Progress-Demo&amp;quot; );&lt;br /&gt;
        progress = new JProgressBar();&lt;br /&gt;
        buttonStart = new JButton( &amp;quot;Start&amp;quot; );&lt;br /&gt;
        buttonStop = new JButton( &amp;quot;Stop&amp;quot; );&lt;br /&gt;
        algorithmus = new Algorithmus(); // Wir brauchen ja einen Algorithmus ;-)&lt;br /&gt;
        // Wenn der Algo nicht läuft, kann man ihn auch nicht stoppen&lt;br /&gt;
        buttonStop.setEnabled( false ); &lt;br /&gt;
        // Der folgende Teil ist nur für das Auge, eine Benutzeroberfläche die&lt;br /&gt;
        // etwas dynamisch ist, kommt immer gut an.&lt;br /&gt;
        Container content = getContentPane();&lt;br /&gt;
        content.setLayout( new GridBagLayout() );&lt;br /&gt;
        JPanel panel = new JPanel( new GridLayout( 1, 2 ));&lt;br /&gt;
        panel.add( buttonStart );&lt;br /&gt;
        panel.add( buttonStop );&lt;br /&gt;
        content.add( progress, new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, &lt;br /&gt;
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, &lt;br /&gt;
                new Insets( 2, 2, 2, 2 ), 0, 0) );&lt;br /&gt;
        content.add( panel, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, &lt;br /&gt;
                GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, &lt;br /&gt;
                new Insets( 2, 2, 2, 2 ), 0, 0) );      &lt;br /&gt;
        // Die Buttons sollen ja auch reagieren können&lt;br /&gt;
        buttonStart.addActionListener( new ActionListener(){&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                start();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        buttonStop.addActionListener( new ActionListener(){&lt;br /&gt;
            public void actionPerformed(ActionEvent e) {&lt;br /&gt;
                stop();&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
        // Geeignete Grösse und Position wählen&lt;br /&gt;
        pack();&lt;br /&gt;
        setLocationRelativeTo( null );&lt;br /&gt;
        // Eigentlich müsste man ja einen WindowListener implementieren, und&lt;br /&gt;
        // den Algorithmus korrekt beenden, aber wir schiessen einfach das&lt;br /&gt;
        // ganze Programm ab&lt;br /&gt;
        setDefaultCloseOperation( EXIT_ON_CLOSE );&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Startet den Algorithmus, das Verhalten ist nicht definiert, wenn der&lt;br /&gt;
     * Algorithmus bereits aktiviert wurde.&lt;br /&gt;
     */&lt;br /&gt;
    protected void start(){&lt;br /&gt;
        buttonStart.setEnabled( false );&lt;br /&gt;
        // Einen neuen Thread herstellen, und starten.&lt;br /&gt;
        new Thread( this ).start();&lt;br /&gt;
        buttonStop.setEnabled( true );&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Stoppt den Algorithmus, immer unter der Annahme, dass er zurzeit&lt;br /&gt;
     * läuft.&lt;br /&gt;
     */&lt;br /&gt;
    protected void stop(){&lt;br /&gt;
        buttonStop.setEnabled( false );&lt;br /&gt;
        algorithmus.setInterrupted( true );&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Die Methode wird aus einem Zusatzthread aufgerufen. Sie startet&lt;br /&gt;
     * den Algorithmus, und sorgt nach seiner Beendigung dafür, dass das&lt;br /&gt;
     * Fenster weiterhin schön aussieht&lt;br /&gt;
     */&lt;br /&gt;
    public void run(){&lt;br /&gt;
        // Zurzeit ist der Algorithmus nicht unterbrochen&lt;br /&gt;
        algorithmus.setInterrupted( false );&lt;br /&gt;
        // Den Algorithmus starten. Die Methode kehrt erst zurück, wenn der&lt;br /&gt;
        // Algo abgearbeitet oder unterbrochen wurde.&lt;br /&gt;
        algorithmus.run( progress );&lt;br /&gt;
        if( algorithmus.isInterrupted() ){&lt;br /&gt;
            /* &lt;br /&gt;
             * Sollte der Algorithmus abgebrochen worden sein, wird die &lt;br /&gt;
             * Progressbar zurück auf den Startwert gesetzt.&lt;br /&gt;
             * &lt;br /&gt;
             * Die Methode &amp;quot;invokeLater&amp;quot; garantiert, dass dass der Code des &lt;br /&gt;
             * übergebenen Runnable&amp;#039;s im Dispatch-Thread&lt;br /&gt;
             * ausgeführt wird. Dies ist notwendig, weil Swing nicht&lt;br /&gt;
             * threadsicher ist.&lt;br /&gt;
             */&lt;br /&gt;
            SwingUtilities.invokeLater( new Runnable(){&lt;br /&gt;
                public void run(){&lt;br /&gt;
                    progress.setMinimum( 0 );&lt;br /&gt;
                    progress.setMaximum( 1 );&lt;br /&gt;
                    progress.setValue( 0 );&lt;br /&gt;
                    buttonStart.setEnabled( true );&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;br /&gt;
        else{&lt;br /&gt;
            /*&lt;br /&gt;
             * Der Algorithmus wurde korrekt beendet, ein Dialog soll den&lt;br /&gt;
             * Benutzer unterrichten, dass das Programm nun geschlossen wird.&lt;br /&gt;
             * &lt;br /&gt;
             * Die Methode &amp;quot;invokeAndWait&amp;quot; garantiert, dass der Code des&lt;br /&gt;
             * Runnable-Objektes, welches übergeben wird, im&lt;br /&gt;
             * EventDispatcher-Thread ausgeführt wird. Ausserdem kehrt die Methode&lt;br /&gt;
             * erst dann zurück, wenn eben dieser Code ausgeführt wurde.&lt;br /&gt;
             */&lt;br /&gt;
            try {&lt;br /&gt;
                SwingUtilities.invokeAndWait( new Runnable(){&lt;br /&gt;
                    public void run(){&lt;br /&gt;
                        JOptionPane.showMessageDialog( Main.this, &lt;br /&gt;
                                &amp;quot;Algorithmus erfolgreich beendet.&amp;quot;, &amp;quot;Beendet&amp;quot;,&lt;br /&gt;
                                JOptionPane.INFORMATION_MESSAGE );&lt;br /&gt;
                    }&lt;br /&gt;
                });&lt;br /&gt;
            } catch (InterruptedException e) {&lt;br /&gt;
                // Kann ja sein, das hier was schiefgeht...&lt;br /&gt;
                e.printStackTrace();&lt;br /&gt;
            } catch (InvocationTargetException e) {&lt;br /&gt;
                e.printStackTrace();&lt;br /&gt;
            }&lt;br /&gt;
            // Programm beenden, nachdem der Dialog geschlossen wurde&lt;br /&gt;
            System.exit(0);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code=java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code=java&amp;gt;&lt;br /&gt;
import javax.swing.JProgressBar;&lt;br /&gt;
import javax.swing.SwingUtilities;&lt;br /&gt;
/**&lt;br /&gt;
 * Der Algorithmus stellt einige langwierige Berechnungen an, für deren&lt;br /&gt;
 * Erklärung hier leider keinen Platz gefunden werden kann.&lt;br /&gt;
 */&lt;br /&gt;
class Algorithmus{&lt;br /&gt;
    /**&lt;br /&gt;
     * Dieser Fortschrittsbalken wird benutzt, um den Fortschritt des Algos&lt;br /&gt;
     * anzuzeigen&lt;br /&gt;
     */&lt;br /&gt;
    private JProgressBar status;&lt;br /&gt;
    /**&lt;br /&gt;
     * Dieser Boolean wird auf &amp;quot;true&amp;quot; gesetzt, sollte der Algorithmus&lt;br /&gt;
     * abgebrochen werden.&lt;br /&gt;
     */&lt;br /&gt;
    private boolean interrupted = false;&lt;br /&gt;
    public Algorithmus(){&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gibt an, ob der Algorithmus abgebrochen wird, oder wurde.&lt;br /&gt;
     * @return true, falls der Algorithmus stoppen soll&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isInterrupted() {&lt;br /&gt;
        return interrupted;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gibt an, ob der Algorithmus abgebrochen werden soll.&lt;br /&gt;
     * @param interrupt true, falls der Algorithmus abgebrochen werden soll,&lt;br /&gt;
     *            andernfalls false.&lt;br /&gt;
     */&lt;br /&gt;
    public void setInterrupted( boolean interrupt ) {&lt;br /&gt;
        interrupted = interrupt;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Die Hauptmethode des Algorithmuses, hier geschehen alle wichtigen&lt;br /&gt;
     * Berechnungen. Leider konnte die Weltformel hier nicht Platz finden,&lt;br /&gt;
     * deshalb beschränkt sich die Methode auf stupides hochzählen eines&lt;br /&gt;
     * Integers :-)&lt;br /&gt;
     * @param progress Der Fortschrittsbalken, welcher den Fortschritt des Algos&lt;br /&gt;
     *            anzeigen wird.&lt;br /&gt;
     */&lt;br /&gt;
    public void run( JProgressBar progress ) {&lt;br /&gt;
        // Den Fortschrittsbalken speichern wir als Instanzvariable. Das&lt;br /&gt;
        // hat den Vorteil, dass jede der 1000 Methoden des Algos Zugriff&lt;br /&gt;
        // auf die Progressbar hat.&lt;br /&gt;
        status = progress;&lt;br /&gt;
        int begin = 13;&lt;br /&gt;
        int end = 65;&lt;br /&gt;
        int current = begin;&lt;br /&gt;
        // Minimum und Maximum des Fortschrittbalkens setzen&lt;br /&gt;
        setMinMax( begin, end );&lt;br /&gt;
        while( current &amp;lt;= end &amp;amp;&amp;amp; !isInterrupted() ){&lt;br /&gt;
            try{&lt;br /&gt;
                Thread.sleep( 100 ); // Kurz warten&lt;br /&gt;
            }&lt;br /&gt;
            catch( InterruptedException e ){&lt;br /&gt;
            }&lt;br /&gt;
            setValue( current++ ); // Hey! Es ist was passiert!&lt;br /&gt;
        }&lt;br /&gt;
        // Instanzvariable auf null setzen, damit der Garbagecollector&lt;br /&gt;
        // allenfalls Müll entfernen kann&lt;br /&gt;
        status = null;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Setzt die minimalen und die maximalen Werte des Fortschrittbalkens. Die&lt;br /&gt;
     * Methode kehrt erst zurück, wenn die Werte tatsächlich gesetzt wurden.&lt;br /&gt;
     * @param min Das Minimum&lt;br /&gt;
     * @param max Das Maximum&lt;br /&gt;
     */&lt;br /&gt;
    private void setMinMax( final int min, final int max ) {&lt;br /&gt;
        try{&lt;br /&gt;
            /*&lt;br /&gt;
             * Diese Methode wird nicht aus dem Dispatcher-Thread aufgerufen. Da&lt;br /&gt;
             * Swing nicht threadsicher ist, müssen wir für eine Synchronisation&lt;br /&gt;
             * sorgen, deshalb wird hier &amp;quot;invokeAndWait&amp;quot; verwendet.&lt;br /&gt;
             */&lt;br /&gt;
            SwingUtilities.invokeAndWait( new Runnable(){&lt;br /&gt;
                public void run() {&lt;br /&gt;
                    status.setMinimum( min );&lt;br /&gt;
                    status.setValue( min );&lt;br /&gt;
                    status.setMaximum( max );&lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;br /&gt;
        catch( Exception e ){&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void setValue( final int value ) {&lt;br /&gt;
        /*&lt;br /&gt;
         * Der Algorithmus sollte nicht unnötig angehalten werden, nur damit die&lt;br /&gt;
         * Progressbar schön aussieht, deshalb &amp;quot;invokeLater&amp;quot;. Es kann nun aber&lt;br /&gt;
         * passieren, dass der Algorithmus abbricht, nachdem er &amp;quot;setValue&amp;quot;&lt;br /&gt;
         * aufgerufen hat (und damit die Variable &amp;quot;status&amp;quot; auf null setzt), das&lt;br /&gt;
         * übergebene Runnable aber erst später ausgeführt wird. Aus diesem&lt;br /&gt;
         * Grund wird ein try-catch-Block benutzt, der die mögliche&lt;br /&gt;
         * NullPointerException abfängt. Alternativ könnte man mit dem Keyword&lt;br /&gt;
         * &amp;quot;synchronized&amp;quot; einen Mechanismus bauen, der verhindert dass die&lt;br /&gt;
         * Variable &amp;quot;status&amp;quot; verändert wird, während wir uns in dieser Methode&lt;br /&gt;
         * befinden (und dann eine einfache if-Abfrage machen).&lt;br /&gt;
         */&lt;br /&gt;
        SwingUtilities.invokeLater( new Runnable(){&lt;br /&gt;
            public void run() {&lt;br /&gt;
                try{&lt;br /&gt;
                    status.setValue( value );&lt;br /&gt;
                }&lt;br /&gt;
                catch( NullPointerException ex ){&lt;br /&gt;
                    // silent exception&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code=java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hier wird ein Frame verwendet. Anstelle eines Frames könnte man auch einen modalen Dialog benutzen, dieser würde solange er sichtbar ist, die Methode blockieren, welche dialog.setVisible(true) aufgerufen hat.&lt;br /&gt;
&lt;br /&gt;
[[Kategorie:Java]]&lt;br /&gt;
[[Kategorie:Swing]]&lt;br /&gt;
&lt;br /&gt;
--[[Benutzer:Beni|Beni]] (01.09.2004, 01:56)&lt;br /&gt;
--[[Benutzer:Bleiglanz|Bleiglanz]] (01.09.2004)&lt;/div&gt;</summary>
		<author><name>L-ectron-x</name></author>
	</entry>
</feed>