383Explicit Parallelization by Other Means
.Net’s S yste m.T h re ad i ng.T h r e ad class
1115
is sealed (noninheritable), so we cannot
extend it as we did in Java. However, we can instantiate an internal Thread object within
our class and use it. Here is the corresponding C# source code:
using System;
using System.IO;
using System.Threading;
namespace My
{
public class NetThread
{
string filename;
double[] doubleData;
Thread thread;
public NetThread(string filename, double[] data)
{
this.filename = filename;
this.doubleData = data;
thread = new Thread(this.run);
}
public void start()
{
thread.Start(); // note the capital S in Start()
}
private void run()
{
try
{
BinaryWriter out = new BinaryWriter( ...