Skip to content

Instantly share code, notes, and snippets.

@donhuvy
Created February 8, 2023 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donhuvy/94dc3edd94890b87721f1530b115976b to your computer and use it in GitHub Desktop.
Save donhuvy/94dc3edd94890b87721f1530b115976b to your computer and use it in GitHub Desktop.
public class Test {
int count;
synchronized void bump() {
count++;
}
static int classCount;
static synchronized void classBump() {
classCount++;
}
}
class BumpTest {
int count;
void bump() {
synchronized (this) {
count++;
}
}
static int classCount;
static void classBump() {
try {
synchronized (Class.forName("BumpTest")) {
classCount++;
}
} catch (ClassNotFoundException e) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment