Nebenläufigkeit.

Status
Nicht offen für weitere Antworten.

jottes

Mitglied
Hi ...
ich habe folgende Klasse...

Code:
public class CountermandWaitScreen extends JDialog implements Runnable
{	
	public static boolean cancelled = false;
	public static JDialog waitDialog;
	public static BookingHistory Hist;
	public WaitScreenListener wListen = new WaitScreenListener();
	public String cid;
	public long readtime;
	
	public CountermandWaitScreen(BookingHistory Hist)
	{
		CountermandWaitScreen.Hist  = Hist;
		waitDialog = this;		
		this.addKeyListener(wListen);
		this.setModal(true);
		
		Dimension ScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int posx = (ScreenSize.width/2)-250;
		int posy = (ScreenSize.height/2)-100;
		JLabel message = new JLabel("Warten auf Karte ...");		
		
		cid = XMLClient.getCardNo();		
		readtime = XMLClient.readTime;		
		
		message.setForeground(Color.WHITE);
		message.setHorizontalAlignment(JLabel.CENTER);
		message.setFont(new Font("Arial",Font.BOLD,28));
		this.setTitle("Abbruch mit Leertaste ...");
		
		this.getContentPane().setLayout(new BorderLayout());
		this.getContentPane().setBackground(Color.BLACK);
		this.getContentPane().add(message,BorderLayout.CENTER);
		this.setSize(500,200);
		this.setLocation(posx, posy);						
		this.setVisible(true);																														
	 }

	public void run() 
	{				
		while(!cancelled)
		{
			System.out.println("in...");
			try
			{
			if(XMLClient.readTime > BookingHistory.openTime)
			{
				System.out.println("im if-zweig");
				Hist.initTab();
				cancelled = true;
				XMLClient.readTime = 0;
				CountermandWaitScreen.waitDialog.dispose();
			}
			 Thread.sleep(1000);
			}
			catch(Exception e)
			{}
		}		
	}
												 			
}

Wenn ich die jetzt in einer anderen Klasse instanziere...

Code:
CountermandWaitScreen WScreen = new ScountermandWaitScreen();

und dann versuche den Thread zu starten...

Code:
WScreen.run();

scheint der nicht gestartet zu werden...
 

Wildcard

Top Contributor
Threads startet man mit new Thread(Runnable).start().
Pass übrigens auf: Swing ist nicht Threadsicher
 

jottes

Mitglied
Alles klar...
das war es auch schon... wenn man nicht mindestens 1x im Jahr was damit coded vergisst man sowas...

;-)
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
W Threads und trotzdem keine Nebenläufigkeit AWT, Swing, JavaFX & SWT 13

Ähnliche Java Themen

Neue Themen


Oben