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