Access to class variables

Hi.
I would like to monitor the change of a class variable from the outside and stop the loop of a task defined in the class when it reaches a certain value.
In the following code, if I use forkA, the simulation ends after mc.value changes to 10, but if I use forkB instead of forkA, the loop does not exit.
I would like to know the reason.
(I used VCS as simulator)


class myclass;
	int value;

	function new;
		value=0;
	endfunction

	task value_inc;
		while(1)begin
			value++;
			#10;
		end
	endtask

	function int get_value;
		return value;
	endfunction
endclass

module	sim_top;

	myclass mc = new();

	initial begin

		fork		//fork A
			mc.value_inc();
			wait(mc.value==10) #1;
		join_any
		disable fork;

		// fork		//fork B
		// 	mc.value_inc();
		// 	wait(mc.get_value()==10) #1;	// The wait statement does not terminate.
		// join_any
		// disable fork;

		$display("mc.value=%-d",mc.value);				//10
		$display("mc.get_value()=%-d",mc.get_value());	//10
		$finish;
	end

	initial begin
		#10000000;
		$display("sim aborted");
		$finish;
	end

endmodule

In reply to hwajeon:

Please refer to this question.

In reply to cgales:

As Dave said, the following works and it makes sense since
this is an event-based simulator. Without a variable argument, the function is never called again.
The function is a function; it just resides there until called.


  function int get_value(int v);
		return v;
	endfunction
endclass
 
module	sim_top;
 
	myclass mc = new();
 
	initial begin
 
		fork		//fork A
			mc.value_inc();
          wait(mc.get_value(mc.value)==10) #1;
		join_any
		disable fork;

In reply to ben@SystemVerilog.us:

A class method does not need a input argument to trigger the event. Writing to a class member does. 3 out of 4 tools on EDAPlayground simulate this correctly. This is a tool bug.

In reply to dave_59:

As you said, it seems to be a tool bug, I ran the same code using Questa and forkA and forkB worked the same. Thank you very much.

Thank you, everyone.
As Dave said, it looks like class methods and other functions are triggered differently.

I wrote this code to try it out.

In this code, only waitB exits successfully.