java methods and race condition in a jsp/servlets application.
Posted
by A.S al-shammari
on Stack Overflow
See other posts from Stack Overflow
or by A.S al-shammari
Published on 2010-05-04T18:11:14Z
Indexed on
2010/05/04
18:18 UTC
Read the original article
Hit count: 259
Hi.
Suppose that I have a method called doSomething()
and I want to use this method in a multithreaded application (each servlet inherits from HttpServlet).I'm wondering if it is possible that a race condition will occur in the following cases:
doSomething()
is not staic method and it writes values to a database.doSomething()
is static method but it does not write values to a database.
what I have noticed that many methods in my application may lead to a race condition or dirty read/write. for example , I have a Poll System , and for each voting operation, a certain method will change a single cell value for that poll as the following:
[poll_id | poll_data ]
[1 | {choice_1 : 10, choice_2 : 20}]
will the JSP/Servlets app solve these issues by itself, or I have to solve all that by myself?
Thanks..
© Stack Overflow or respective owner