2 *******************************************************************************
\r
3 * Copyright (C) 2008, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
7 package com.ibm.icu.dev.test.lang;
\r
9 import java.util.LinkedList;
\r
10 import java.util.List;
\r
11 import java.util.ListIterator;
\r
13 import com.ibm.icu.dev.test.TestFmwk;
\r
14 import com.ibm.icu.lang.UCharacter;
\r
20 public class UCharacterThreadTest extends TestFmwk {
\r
21 // constructor -----------------------------------------------------------
\r
24 * Private constructor to prevent initialisation
\r
26 public UCharacterThreadTest()
\r
30 // public methods --------------------------------------------------------
\r
32 public static void main(String[] arg)
\r
36 UCharacterThreadTest test = new UCharacterThreadTest();
\r
41 e.printStackTrace();
\r
47 // Test multi-threaded parallel calls to UCharacter.getName(codePoint)
\r
48 // Regression test for ticket 6264.
\r
50 public void TestUCharactersGetName() throws InterruptedException {
\r
51 List threads = new LinkedList();
\r
52 for(int t=0; t<20; t++) {
\r
53 int codePoint = 47 + t;
\r
54 String correctName = UCharacter.getName(codePoint);
\r
55 GetNameThread thread = new GetNameThread(codePoint, correctName);
\r
57 threads.add(thread);
\r
59 ListIterator i = threads.listIterator();
\r
60 while (i.hasNext()) {
\r
61 GetNameThread thread = (GetNameThread)i.next();
\r
63 if (!thread.correctName.equals(thread.actualName)) {
\r
64 errln("FAIL, expected \"" + thread.correctName + "\", got \"" + thread.actualName + "\"");
\r
69 private static class GetNameThread extends Thread {
\r
70 private final int codePoint;
\r
71 private final String correctName;
\r
72 private String actualName;
\r
74 GetNameThread(int codePoint, String correctName) {
\r
75 this.codePoint = codePoint;
\r
76 this.correctName = correctName;
\r
80 for(int i=0; i<10000; i++) {
\r
81 actualName = UCharacter.getName(codePoint);
\r
82 if (!correctName.equals(actualName)) {
\r