Search code examples
javamultithreadingthread-safetyhtmlunit

HtmlUnit: one WebClient per thread - is it thread safe?


I have many threads. Each thread creates and uses it's own WebClient (HtmlUnit framework). No one thread uses WebClient's instance from other thread. Is it thread safe?


Solution

  • From the documentation

    Note: a WebClient instance is not thread safe. It is intended to be used from a single thread.

    As long as each thread creates its own WebClient, you won't have any issues. From what you said, you're doing the right thing.