-3

I declared the variable public static in the first class A so, I can access it from Class B but, the variable can be only calculated in the main method of Class A and it's calculable I get the value in the same class but in the class B I get a zero :

public class A {
public static double CloudMakespan;


 public static double  CalculCloudMakespan(){
                          
                         double cloudms = 0;
   
                         int A= SimulationSetup.getCloudlet().length-1;
                         
  double executionEndTimeLastCloudlet = SimulationSetup.getCloudlet([A].getFinishTime();
        
  double executionStartTimeFisrtCloudlet=SimulationSetup.getCloudlet()[0].getExecStartTime();
                         
                          cloudms= executionEndTimeLastCloudlet - executionStartTimeFisrtCloudlet;
                       
                          return cloudms; }


`public static void main(String[] args){



Cloudsim.startSimulation();
Cloudsim.EndSimulation();
CloudMakespan=CalculCloudMakespan();


}

i tried to do this in Class B

Class B{
private double totalMakespan;
private tasksMakespan;

public double doSomeCalCul(){

totalMakespan=ClassA.CloudMakespan+taskMakespan;


}



}

the problem is the method DoSomeCalcul() is called before the calcul of the variable Cloudmakespan

and I can't call it after that because starting the simulation is the result of specified instructions one of them is calculating the Cloud Makespanyour text

  • `and the problem is the methos DoSomeCalcul() is called before the calcul of the variable Cloudmakespan` - then this is impossible. You cannot do `DoSomeCalcul` if a required value has not been calculated yet. – f1sh Mar 14 '23 at 11:53
  • can i use a thread that do a simulation to calcul the variable before the final simulation? – Mohammed El-Amine ghomari Mar 14 '23 at 11:56

1 Answers1

0

Maybe you can loop multiple times in "DoSomeCalcul" until variable Cloudmakespan is ready. Of course, It is low efficiency in this way. It is better to call back "DoSomeCalcul" when Cloudmakespan is ready.

Stone
  • 155
  • 1
  • 6