diff --git a/src/modules/_Image_JPEG/image_jpeg.c b/src/modules/_Image_JPEG/image_jpeg.c
index 8d1352309008cb58c80a24bbd02b4f84354c8c83..0617f31fbccd95ec7733b0cbdbe606c788c4890d 100644
--- a/src/modules/_Image_JPEG/image_jpeg.c
+++ b/src/modules/_Image_JPEG/image_jpeg.c
@@ -1,5 +1,5 @@
 /*
- * $Id: image_jpeg.c,v 1.20 1999/02/10 21:52:14 hubbe Exp $
+ * $Id: image_jpeg.c,v 1.21 1999/04/14 21:05:15 hubbe Exp $
  */
 
 #include "global.h"
@@ -23,7 +23,7 @@
 #ifdef HAVE_STDLIB_H
 #undef HAVE_STDLIB_H
 #endif
-RCSID("$Id: image_jpeg.c,v 1.20 1999/02/10 21:52:14 hubbe Exp $");
+RCSID("$Id: image_jpeg.c,v 1.21 1999/04/14 21:05:15 hubbe Exp $");
 
 #include "pike_macros.h"
 #include "object.h"
@@ -35,6 +35,7 @@ RCSID("$Id: image_jpeg.c,v 1.20 1999/02/10 21:52:14 hubbe Exp $");
 #include "mapping.h"
 #include "error.h"
 #include "stralloc.h"
+#include "threads.h"
 
 #ifdef HAVE_JPEGLIB_H
 
@@ -372,6 +373,7 @@ static void image_jpeg_encode(INT32 args)
    y=img->ysize;
    s=img->img;
 
+   THREADS_ALLOW();
    while (y)
    {
       int n,i,y2=y;
@@ -393,6 +395,7 @@ static void image_jpeg_encode(INT32 args)
       
       y-=y2;
    }
+   THREADS_DISALLOW();
 
    free(tmp);
 
@@ -541,6 +544,7 @@ static void image_jpeg_decode(INT32 args)
    y=img->ysize;
    d=img->img;
 
+   THREADS_ALLOW();
    while (y)
    {
       int n,m;
@@ -571,6 +575,7 @@ static void image_jpeg_decode(INT32 args)
 	    d->r=d->g=d->b=*(s++),d++;
       y-=n;
    }
+   THREADS_DISALLOW();
 
    free(tmp);