Check out the latest documentation.

Multi-Threading - Version 3

In the V3 API providers can no longer be given ThreadPools to speed up an individual match. However, once a provider has been initialised the match method can be called concurrently, giving a speed increase over a range of user agents.

Multi-Threading - Version 2

As of 2.2.8.2, Multi-Threading can be enabled in the Detector by passing a ThreadPoolExecutor to the Factory, Provider or Reader.Create methods. Note that it is the developer's responsibility to shut down the ThreadPoolExecutor once it is no longer needed for Detection. The ThreadPoolExecutor should not be shut down if a Provider is still using it. If no thread pool is supplied (or if it is null) then single threading will be used instead.

									ThreadPoolExecutor threadPool = 
  (ThreadPoolExecutor)Executors.newCachedThreadPool();


										
										// using a threadpool to create a new provider
										
									
Provider p = 
										
										new
										
									 Provider(threadPool);


										
										// using a threadpool to create a provider from a Reader method
										
									
Provider p = Reader.create(
										
										"PATH_TO_PREMIUM_DATA"
										
									, threadPool);


										
										// using a threadpool in a factory that will create multi-threaded providers
										
									
Factory factory = 
										
										new
										
									 Factory();
factory.initialize(
										
										"51Degrees.dat"
										
									, 
										
										"LICENCE_KEY_HERE"
										
									, threadPool);