y987425112 commented on issue #145: Adding volatile keywords to member variables URL: https://github.com/apache/tomcat/pull/145#issuecomment-470489493 ``` 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org