-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathresult.json
More file actions
17 lines (17 loc) · 3.29 KB
/
Copy pathresult.json
File metadata and controls
17 lines (17 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"flag": 3,
"ast_output": "public class WrongCounterDemo {\r\n\r\n private static final int INC_COUNT = 100000000;\r\n\r\n private volatile int counter = 0;\r\n\r\n public static void main(String[] args) throws Exception {\r\n WrongCounterDemo demo = new WrongCounterDemo();\r\n System.out.println(\"Start task thread!\");\r\n Thread thread1 = new Thread(demo.getConcurrencyCheckTask());\r\n thread1.start();\r\n Thread thread2 = new Thread(demo.getConcurrencyCheckTask());\r\n thread2.start();\r\n thread1.join();\r\n thread2.join();\r\n int actualCounter = demo.counter;\r\n int expectedCount = INC_COUNT * 2;\r\n if (actualCounter != expectedCount) {\r\n System.err.printf(\"Fuck! Got wrong count!! actual %s, expected: %s.%n\", actualCounter, expectedCount);\r\n } else {\r\n System.out.println(\"Wow... Got right count!\");\r\n }\r\n }\r\n\r\n ConcurrencyCheckTask getConcurrencyCheckTask() {\r\n return new ConcurrencyCheckTask();\r\n }\r\n\r\n //threadAble_class\r\n private class ConcurrencyCheckTask implements Runnable {\r\n\r\n @Override\r\n @SuppressWarnings(\"NonAtomicOperationOnVolatileField\")\r\n public void run() {\r\n for (int i = 0; i < INC_COUNT; ++i) {\r\n ++counter;\r\n }\r\n }\r\n }\r\n}\r\n",
"classes": [
{
"class_index": 0,
"class_code": "private class ConcurrencyCheckTask implements Runnable {\r\n\r\n @Override\r\n @SuppressWarnings(\"NonAtomicOperationOnVolatileField\")\r\n public void run() {\r\n for (int i = 0; i < INC_COUNT; ++i) {\r\n ++counter;\r\n }\r\n }\r\n}",
"class_flag": 0
},
{
"class_index": 1,
"class_code": "public class WrongCounterDemo {\r\n\r\n private static final int INC_COUNT = 100000000;\r\n\r\n private volatile int counter = 0;\r\n\r\n public static void main(String[] args) throws Exception {\r\n WrongCounterDemo demo = new WrongCounterDemo();\r\n System.out.println(\"Start task thread!\");\r\n Thread thread1 = new Thread(demo.getConcurrencyCheckTask());\r\n thread1.start();\r\n Thread thread2 = new Thread(demo.getConcurrencyCheckTask());\r\n thread2.start();\r\n thread1.join();\r\n thread2.join();\r\n int actualCounter = demo.counter;\r\n int expectedCount = INC_COUNT * 2;\r\n if (actualCounter != expectedCount) {\r\n System.err.printf(\"Fuck! Got wrong count!! actual %s, expected: %s.%n\", actualCounter, expectedCount);\r\n } else {\r\n System.out.println(\"Wow... Got right count!\");\r\n }\r\n }\r\n\r\n ConcurrencyCheckTask getConcurrencyCheckTask() {\r\n return new ConcurrencyCheckTask();\r\n }\r\n\r\n //threadAble_class\r\n private class ConcurrencyCheckTask implements Runnable {\r\n\r\n @Override\r\n @SuppressWarnings(\"NonAtomicOperationOnVolatileField\")\r\n public void run() {\r\n for (int i = 0; i < INC_COUNT; ++i) {\r\n ++counter;\r\n }\r\n }\r\n }\r\n}",
"class_flag": 1
}
],
"classnum": 2
}