Added "synchronized" method to create random number in case of multi-thread issue
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 11 Oct 2006 10:10:16 +0000 (10:10 +0000)
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 11 Oct 2006 10:10:16 +0000 (10:10 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1722 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java

index fbf69e2..761a0ef 100644 (file)
@@ -148,7 +148,7 @@ public class Tool implements EfiDefine, Section {
         } \r
 \r
         try {\r
         } \r
 \r
         try {\r
-            this.outputFileName = "Temp" + ran.nextInt();\r
+            this.outputFileName = "Temp" + getRand();\r
             argument   = toolArgList + inputFiles.toStringWithSinglepPrefix(" -i ") \r
                          + tempInputFile.toString(" ")+ " -o " + outputFileName;\r
             EdkLog.log(this, EdkLog.EDK_VERBOSE, command + " " + argument);\r
             argument   = toolArgList + inputFiles.toStringWithSinglepPrefix(" -i ") \r
                          + tempInputFile.toString(" ")+ " -o " + outputFileName;\r
             EdkLog.log(this, EdkLog.EDK_VERBOSE, command + " " + argument);\r
@@ -164,7 +164,8 @@ public class Tool implements EfiDefine, Section {
                     file.delete();\r
                 }\r
             }\r
                     file.delete();\r
                 }\r
             }\r
-        } catch (Exception e) {\r            EdkLog.log(e.getMessage());\r
+        } catch (Exception e) {\r
+            EdkLog.log(e.getMessage());\r
             throw new BuildException("Execution of externalTool task failed!\n");\r
         }\r
     }\r
             throw new BuildException("Execution of externalTool task failed!\n");\r
         }\r
     }\r
@@ -236,7 +237,16 @@ public class Tool implements EfiDefine, Section {
     \r
     public void addGenSection(GenSectionTask genSect){\r
         this.gensectList.add(genSect);\r
     \r
     public void addGenSection(GenSectionTask genSect){\r
         this.gensectList.add(genSect);\r
-    }    \r
+    }\r
+\r
+    /**\r
+     Get random number.\r
+\r
+     @returns   The random integer.\r
+     **/\r
+    public synchronized int getRand() {\r
+        return ran.nextInt();\r
+    }\r
 }\r
 \r
 \r
 }\r
 \r
 \r