# Multithreaded Filtering

To ensure multithreaded filter processes are thread-safe, you must create a unique Filter context for every thread by instantiating a `Filter` object. In addition, threads must not share context objects, and the same context object must be used for all API calls in the same thread. Creating a context object for every thread does not affect performance because the context object uses minimal resources.

For example, your Java code should have the following logic in a thread:

    m_objFilter = new Filter();
    m_objFilter.setFilterDirectory(m_filterDirectory);
    m_objFilter.setInputSource(infile);
    m_objFilter.getDocFormatInfo();

    if (objFilter.canFilter() == true)

    m_objFilter.filterTo(outfile);

    m_objFilter.shutdownFilter();

© Copyright 2016-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm