This site requires JavaScript, please enable it in your browser!
Greenfoot back
Game/maniac
Game/maniac wrote ...

2013/12/16

How do I create and use a lock?

Game/maniac Game/maniac

2013/12/16

#
How do I create and use a lock for multi-threading with userInfo?
bourne bourne

2013/12/16

#
Here is a basic example with my UserInfoSemaphore class:
while (!UserInfoSemaphore.request()) // Wait until gain the lock
{}

myUserInfo.setInt(1, 0);
myUserInfo.setInt(2, 0);
myUserInfo.setString(0, "");
myUserInfo.store();

UserInfoSemaphore.release(); // Unlock whenever finished
lordhershey lordhershey

2013/12/16

#
Can you use the Synchronized keyword?
bourne bourne

2013/12/16

#
My UserInfoSemaphore class does, but UserInfo must not
You need to login to post a reply.