Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 473D218E77 for ; Thu, 8 Oct 2015 11:36:11 +0000 (UTC) Received: (qmail 92571 invoked by uid 500); 8 Oct 2015 11:36:11 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 92548 invoked by uid 500); 8 Oct 2015 11:36:11 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 92536 invoked by uid 99); 8 Oct 2015 11:36:10 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2015 11:36:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 48F26C4AE5 for ; Thu, 8 Oct 2015 11:36:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.181 X-Spam-Level: ** X-Spam-Status: No, score=2.181 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id knwuvHFw941K for ; Thu, 8 Oct 2015 11:36:03 +0000 (UTC) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 55D1E203BC for ; Thu, 8 Oct 2015 11:36:03 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so20873355wic.1 for ; Thu, 08 Oct 2015 04:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=SkgkKQp3cUK6dFT7YPa+DJZDpsuWNXioHKz+OPrIDIQ=; b=MibTXtSFiQUBUmG+60QmBpJfVUMb+micZWSt5n9YFAC6Zpa0lXFuAGbI9pGKekUAfd iTXKAGzTYOZb8GTn9Jb/Hv5FNDFPnSnWWaeIwwAbC4FmujRoE7j7ViudU6eeHZYQm2yH 47tEaSamtC3oieotiMb3SFk1hncMm+bbUzfUgCT1CxD9GjElLZl0Q5HDoebi7GmPY2+t 2HPG62cepjd8G8KO//wRKmbt3/zs+LcJ54mmru6KyQzoDMPTSa/Ufqq3QD8jjdXfhEwG e7Rp2bECubQaphfjeIv7dpZkhTSPXtKdVsjiZAV7loBwPA5E/9dw6NlDalnKD2cv6OnQ RPZA== X-Received: by 10.180.35.163 with SMTP id i3mr3716856wij.55.1444304161950; Thu, 08 Oct 2015 04:36:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.16.17 with HTTP; Thu, 8 Oct 2015 04:35:42 -0700 (PDT) In-Reply-To: <56163E72.6020600@gmx.de> References: <56163E72.6020600@gmx.de> From: Roberto Nibali Date: Thu, 8 Oct 2015 13:35:42 +0200 Message-ID: Subject: Re: PDFont - thread save? To: users@pdfbox.apache.org Content-Type: multipart/alternative; boundary=e89a8f83a3f9855e12052196447d --e89a8f83a3f9855e12052196447d Content-Type: text/plain; charset=UTF-8 Hi Short answer: from the pdfbox FAQ entry ( https://pdfbox.apache.org/1.8/faq.html#threadsafe) point of view: no, generally you cannot assume thread-safety with the pdfbox library. However, it is my personal experience that you can easily parallelize certain tasks calling pdfbox library methods using a miminal amount of care and design in the way you invoke and synchronize the threads. With regard to your issue, I'm afraid that you would need to provide more information: - What is the exact error message you get? - How exactly is your libertine_R variable defined? E.g.: a global static final PDFont? - How do you use your libertine_R variable inside the threads? - Could you share some more of your code, especially the part of the worker threads? - Which framework do you use for your multi-threaded approach? Best regards Roberto On Thu, Oct 8, 2015 at 11:59 AM, M. Niedermair wrote: > Hello there, > > I load the font "Linux Libertine" in a factory as a singleton (I create > several hundred PDFs with this font.). > > libertine_R = PDTrueTypeFont.loadTTF(document, > FontLibertine.class.getResourceAsStream("ttf/LinLibertine_Rah.ttf")); > > In single-threaded, this also works without problems. > But if I start multiple threads that use the Font singelton, there is an > error. I run four threads per core (4x8 = 32). > > As a stopgap, I load the font in each thread individually. > Is there a better solution? > > Michael > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > > --e89a8f83a3f9855e12052196447d--