1 Star 0 Fork 1.3K

emscripten/OpenArkCompiler

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
ThreadTest.java 1.36 KB
Copy Edit Raw Blame History
BinaryFZ authored 2020-03-31 09:38 +08:00 . opensource FE and BE source code
/*
* Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved.
*
* OpenArkCompiler is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
*
* http://license.coscl.org.cn/MulanPSL
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
* FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v1 for more details.
*/
public class ThreadTest {
static volatile long flag = 0L;
static int number = 0;
static class FirstThread extends Thread {
public void run() {
while(flag != Long.MAX_VALUE) {
}
System.out.println(number);
}
}
static class SecondThread extends Thread {
public void run() {
number = 42;
flag = Long.MAX_VALUE;
}
}
public static void main(String args[]) {
FirstThread t1 = new FirstThread();
SecondThread t2 = new SecondThread();
t1.start();
t2.start();
try {
t1.join();
t2.join();
} catch (InterruptedException e) {
System.out.println("INTERRUPTED_MESSAGE");
}
System.out.println("OK");
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/emscripten/OpenArkCompiler.git
git@gitee.com:emscripten/OpenArkCompiler.git
emscripten
OpenArkCompiler
OpenArkCompiler
master

Search