Change the local value and Thread safe using Java

Hi i find that, this approach is not thread safe, because may other thread change the local value

@mesbahiAouam

Could you please share some more detail about your query along with following resources here for testing:

  • Your input Word document.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi Tahir,

Could you please provide a thread safe alternative on How do I change the Locale for a Word document so numeric formatting works? - #6 by tahir.manzoor ?

Does Aspose maybe in the meantime got another way of specifying the locale in which Word fields need to be updated, that is more thread safe?

regards,

@avandenhoogen The only way to specify locale is the following

// Set locale for the current thread.
Locale current = CurrentThreadSettings.getLocale();
CurrentThreadSettings.setLocale(Locale.forLanguageTag("en-US"));

// Open document
Document doc = new Document("C:\\temp\\in.docx");
// Process document
// ........................

// Restore locale.
CurrentThreadSettings.setLocale(current);

Since Aspose.Words is thread-safe as long you are working with a document instance in one thread such method is thread safe.

1 Like

Thank you very much!

1 Like