Java:Can you provide a multi-threaded read cad file demo

Can you provide a multi-threaded read cad file demo?I made this error when I was using multithreading 微信图片_20200427164732.png (28.3 KB)

This is my demo filedemo.zip (1.6 KB)

All DWG files in a folder are read

@fei3977071,

You can consider the following multi-threaded sample code and change w.r.t your requirements.

int toProcess = 10;
for (int i = 0; i < toProcess; i++)
{
new System.Threading.Thread(() =>
{
using (
var fileStream = new System.IO.FileStream(@"sample.dwg", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
{
Aspose.CAD.Image img = Aspose.CAD.Image.Load(fileStream);
// Create an instance of CadRasterizationOptions
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set page width & height
rasterizationOptions.PageWidth = 1200;
rasterizationOptions.PageHeight = 1200;

                    // Create an instance of PngOptions for the resultant image
                    ImageOptionsBase options = new Aspose.CAD.ImageOptions.PngOptions();
                    //Set rasterization options
                    options.VectorRasterizationOptions = rasterizationOptions;

                    var convertedStream = new System.IO.MemoryStream();
                    img.Save(convertedStream, options);
                }
            }).Start();
        }
  • Can you provide a Java version?thanks

@fei3977071,

You can please try using latest Aspose.CAD for Java 20.3 on your end.