Ola Galera.
Estou com um problema,preciso que uma while espere um comando terminar de ser executado para continuar o loop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package a.i.d.s.server;
import static a.i.d.s.server.AIDSServer.*;
import static a.i.d.s.server.Controle_GUI.*;
import static a.i.d.s.server.Information_Host.HostsIp;
import java.io.IOException;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Matheus
*/
public class Connect_Client extends Thread{
static String ConnectIp;
public static Socket Client;
public static boolean Connect_Stats;
public static boolean close;
public static boolean Connect_All;
static int TIME_OUT = 120;
public static boolean SendCommands;
public void run(){
> while (true) {
if(Connect_Op == 0){
ConnectIp = null;
Connect_All = false;
}
if(Connect_Op == 1){
Connect_All = false;
System.out.println("Connecting...");
ConnectIp = Box1.getSelectedItem().toString();
try {
Client = new Socket(ConnectIp,Port_Client);
Connect_Stats = Client.isConnected();
TIME_OUT_TIMER timer = new TIME_OUT_TIMER();
Thread threadTime = new Thread((Runnable) timer);
threadTime.start();
> if(TIME_OUT <= 0){
> close = true;
> }
> if(SendCommands == true){`
> new Commands();
> }
if(close == true){
Client.close();
label4.setText("Connection Closed");
label4.setForeground(java.awt.Color.BLUE);
Connect_Op = 0;
TIME_OUT = 120;
SendCommands = false;
close = false;
}
} catch (IOException ex) {
Logger.getLogger(Connect_Client.class.getName()).log(Level.SEVERE, null, ex);
}
}
}//While
}
public static void main(String[] args) throws IOException {
}//Main
}//Class
Coloquei citações na while e nos códigos que eu quero que ela espere serem executados.