
June 21st, 2000, 05:04 PM
|
|
Junior Member
|
|
Join Date: Jun 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
How does one write thread-safe code segments in PHP? Every counter (using a flat file) I've seen in PHP looks like this:
// read value from file
// increment value
// write value to file
Of course, if you have two clients getting this page, and one of them reads the value before the other writes, you'll have an inaccurate count.
So, generally how do you write thread-safe code in PHP. In JSP you have something like:
synchronize(application) {
[code goes here]
}
Is their a similar construct in PHP, or do you have to roll your own?
Thanks,
John
|