Freertos + return without restart all code

Hi. I apologise for the las topic. I dont know as delate.

Well. I have a problem. I am working in FreeRTOS structure. I explain my problem through a easy example show down:

#include <Arduino_FreeRTOS.h>

int k=0;

void HTTP( void *pvParameters );

void setup() {                 
  Serial.begin(9600);
  xTaskCreate(HTTP,(const portCHAR *)"HTTP",128,NULL,1,NULL);
}

void loop(){}

void HTTP( void *pvParameters ){
  Serial.println(k);
  k=1;
  Serial.println(k);
  vTaskDelay(2000/portTICK_PERIOD_MS);
  return;
  Serial.println("Not show");
  
}

The result shown in windows serial is the next:

0
1
0
1
0
1

And this is my proble, I am seeking the result is

0
1
1
1
1
1

I have a problem becouse it restart all the code and initialize the variables another again. And it is a problem becouse this affects all fuctions.

Can you help me?

thanks

in a RTOS Tasks are normally implemented as an infinite loop, and must never attempt to return or exit from their implementing function (or should delete themselves)

You have a very nice "return" in your HTTP task...

J-M-L:
in a RTOS Tasks are normally implemented as an infinite loop, and must never attempt to return or exit from their implementing function (or should delete themselves)

You have a very nice "return" in your HTTP task...

And there are nothing that I can use for come back to begin fuction when I want, in the middle of code? Something like "got to point" or like that?

C has a goto function, which might be useful in this case,

Do you understand the concept of tasks ?

J-M-L:
Do you understand the concept of tasks ?

Yes, but I dont understand the mechanism so Freertos do it posible. Is to say, FreeRTOS has developed a complex system who offers you in a page web many fuctions you can use to do specific things. And this is my question all this. After searching for information and not finding what I want , I hope someone who knows explain me if there is some similar fuction or some way to do it

KeithRB:
C has a goto function, which might be useful in this case,

Yes I know it jajaja. For this reazon I wrote It. Thanks

Can you explain why you need FreeRTOS? (If you need it and need to join tasks you might want to read about semaphore and mutex)