我项目中的并发错误 [英] Concurrency Error in my project

查看:83
本文介绍了我项目中的并发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,两个人试图在同一时刻打开两个不同的页面。经常发生的是,有时页面是混合的,即有时候第一个人获得另一个页面,反之亦然。



我试图检查会话并通过打印查看状态数据值,但它们也被交换和更改。不保持并发。请尽快帮我解决问题。

In my website when two people try to open two different pages at the same instant. It often happens that sometimes pages are mixed, i.e. sometimes first person gets page of another or vice versa.

I tried to check the session and view state data by printing the value, but they are also swapped and changed. Concurrency is not maintained. Please help me resolve the problem as soon as possible.

推荐答案

正如Praveen所说,你必须在某处宣布并使用静态变量。



会发生什么,静态变量的生命是应用程序级别。因此,当您声明并使用它时,第一个用户将数据设置到其中。同时,当其他用户看到该页面时,它会显示上次更新的值,而不是默认值。这是静态变量的本质。
As Praveen says, you must be having Static Variables declared and used somewhere.

What happens is, Static variable's life is application level. So, when you declare and use that, the first user sets data into it. At the same time, when other users sees the page, it shows the last updated value, not the default one. This is the nature of Static variable.


这篇关于我项目中的并发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆