@Override
    public void run() {
      try {

        oos.writeObject(MyPack);
        oos.flush();

        result = (ResultPack) ois.readObject();

        if ((System.currentTimeMillis() - startTime) < NetInfo.waitTime) {
          if (result == null) callingparent.setResult(null, null);
          else callingparent.setResult(result.getresult(), result.getstate());
        }

        oos.close();
        ois.close();

        in.close();
        out.close();

        mysocket.close();

        oos = null;
        ois = null;

        in = null;
        out = null;
        mysocket = null;

      } catch (IOException ex) {
        callingparent.setResult(null, null);
      } catch (ClassNotFoundException ex) {
        callingparent.setResult(null, null);
      }
    }
    @Override
    public void run() {
      try {
        processTime = System.currentTimeMillis();
        myPack = (Pack) ois.readObject();
        functionName = myPack.getfunctionName();
        paramTypes = myPack.getparamTypes();
        paramValues = myPack.getparamValues();
        state = myPack.getstate();
        stateDType = myPack.getstateType();
        timestamps = myPack.getTimeStamps();

        if (functionName != null && functionName.length() > 0) {
          try {

            System.out.println("Trying to load and execute");
            Class cls = Class.forName(stateDType.getName());

            timestamps.add(processTime + ",server1");

            /*System.out.println(""+stateDType.getName());

            System.out.println("functionsName: " + functionName.toLowerCase());
            System.out.println("paramTypes: " + paramTypes.toString());*/

            Method method = cls.getDeclaredMethod(functionName, paramTypes);

            try {

              /** support for caching results */

              /** cache using the parameters as key of the result can be possible */
              // boolean processed = TreeManager.getInstance().exists(paramValues[0]);

              // System.out.println("param1:" + (int[]) paramValues[0]);
              // System.out.println("param1:" + paramValues[1]);
              // System.out.println("param1:" +  paramValues[2]);

              oos.flush();
              Object result = method.invoke(state, paramValues);
              ResultPack rp = new ResultPack(result, state);

              rp.setTimeStamps(timestamps);

              // System.out.println("Size in bytes: " + sizeInBytes(rp));
              oos.flush();
              oos.writeObject(rp);
              // System.out.println("Object wrote it");
              oos.flush();
              // System.out.println("Object executed and flushed: " + (System.currentTimeMillis() -
              // processTime));

              System.out.println("Object executed and flushed:");

              // System.out.println("Object executed and flushed: " + (System.currentTimeMillis() -
              // processTime));

            } catch (IllegalAccessException ex1) {
              returnnull(oos);
              System.out.println("Hubo problema 1: " + ex1.getMessage());
            } catch (InvocationTargetException ex2) {
              returnnull(oos);
              System.out.println("Hubo problema 2: " + ex2.getCause());
            } catch (Exception ex3) {
              ResultPack rp = new ResultPack(null, state);
              oos.writeObject(rp);
              oos.flush();
              System.out.println("Hubo problema 3" + ex3.getCause());
            }

          } catch (ClassNotFoundException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 4");
          } catch (IllegalArgumentException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 5");
          } catch (NoSuchMethodException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 6");
          } catch (SecurityException ex) {
            returnnull(oos);
            System.out.println("Hubo problema 7");
          } finally {

            oos.close();
            ois.close();

            in.close();
            out.close();

            mysocket.close();

            oos = null;
            ois = null;

            in = null;
            out = null;
            mysocket = null;
          }
        } else {
          returnnull(oos);
        }
      } catch (IOException ex) {
        returnnull(oos);
        System.out.println("Hubo problema 8");
      } catch (ClassNotFoundException ex) {
        returnnull(oos);
        System.out.println("Hubo problema 9");
        ex.printStackTrace();
      } finally {
        makeconnection();
      }
    }