You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GitBox <gi...@apache.org> on 2019/03/07 11:19:42 UTC
[GitHub] [tomcat] y987425112 removed a comment on issue #145: Adding
volatile keywords to member variables
y987425112 removed a comment on issue #145: Adding volatile keywords to member variables
URL: https://github.com/apache/tomcat/pull/145#issuecomment-470488340
`package com.ydy.thread.volatile2;
public class VolatileTest {
public static void main(String[] args) throws Exception {
Task task=new Task();
task.start();
Thread.sleep(2000);
task.setFlag(false);
System.out.println("task.setFlag(true)");
}
private static class Task extends Thread{
private boolean flag=true;
private int num=0;
@Override
public void run() {
// TODO Auto-generated method stub
while(getFlag()) {
num ++;
}
}
private boolean getFlag() {
return flag;
}
public synchronized void setFlag(boolean flag) {
this.flag = flag;
}
}
}`
Dead cycle
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org