In mysql we use @ for user-defined variable, which stays alive until the connection is closed. In java, when multiple threads share one connection pool, while calling a stored procedure concurrently to get rankings:
BEGIN
SET @rank := 0;
SELECT @rank := @rank + 1 as rank FROM ...
END
If 2 threads are calling the procedure at same time, without synchronizing @rank, is it possible @rank may return unexpected result?
Is there a better way to handle this situation?
Thanks!