 more than one consumer, so you need to send a sentinel once for each running consumer, and guarantee that each consumer will only consume one sentinel, to ensure that each consumer receives its shutdown sentinel.
Second, remember that Queue defines an interface, and that when possible, code should behave regardless of the underlying Queue.  You might have a PriorityQueue, or you might have some other class that exposes the same interface and returns values in some other order.
Unfortunately, it's hard to deal with both of these.  To deal with the general case of different queues, a consumer that's shutting down must continue to consume values after receiving its shutdown sentinel until the queue is empty.  That means that it may consume another thread's sentinel.  This is a weakness of the Queue interface: it should have a Queue.shutdown call to cause an exception to be thrown by all consumers, but that's missing.
So, in practice:

if you're sure you're only ever using a regular Queue, simply send one sentinel per thread.
if you may be using a PriorityQueue, ensure that the sentinel has the lowest priority.

 Q:

How to format double values to E format with specified exponent?

Suppose I have two numbers, 0.0001 and 0.00001.
When I try to format them using "e" notation in C#, I get the following:
double val = 0.0001;
Console.Out.WriteLine(val.ToString("e")) //prints 1e-4

double val2 = 0.00001;
Console.Out.WriteLine(val2.ToString("e")) //prints 1e-5

But I would like to format both 0.0001 and 0.00001 to show the same exponent like this: 
0.0001-> 100e-6
0.00001->10e-6
How can I achieve this?

A:

If you want this result:
    1.0      = 1.00
    0.1      = 0.10
    0.01     = 0.010
    0.001    = 1.00e-3
    0.0001   = 0.10e-3
    0.00001  = 0.010e-3
    0.000001 = 1.00e-6

The use this code:
class Program
{
    ///
more than one consumer, so you need to send a sentinel once for each running consumer, and undertake that each consumer will merely consume one sentinel, to guarantee that each consumer receive its shutdown sentinel. 
 Second, commemorate that Queue define an interface, and that when possible, code should act regardless of the implicit in Queue.   You might have a PriorityQueue, or you might get some other class that exposes the same interface and returns values in some early order. 
 Unfortunately, it's hard to deal with both of these.   To consider with the general case of unlike queues, a consumer that's close down must continue to devour values after receiving its shutdown sentinel until the queue is empty.   That entail that it may consume another thread's sentinel.   This is a weakness of the Queue interface: it should have a Queue.shutdown margin call to cause an exception to be thrown by all consumers, but that's missing. 
 So, in practice: 

 if you're sure you're only ever using a even Queue, simply send one lookout per screw thread. 
 if you may be use a PriorityQueue, ensure that the sentinel has the lowest priority. 

  Q: 

 How to format double values to E format with assign exponent? 

 Suppose I have two numbers, 0.0001 and 0.00001. 
 When I try to format them using " einsteinium " notation in C #, I get the following: 
 bivalent val = 0.0001; 
 Console. Out. WriteLine(val. ToString("e ") ) //prints 1e-4 

 double val2 = 0.00001; 
 Console. Out. WriteLine(val2.ToString("e ") ) //prints 1e-5 

 But I would wish to format both 0.0001 and 0.00001 to show the same exponent like this: 
 0.0001- > 100e-6 
 0.00001->10e-6 
 How can I achieve this? 

 A: 

 If you want this result: 
     1.0       = 1.00 
     0.1       = 0.10 
     0.01      = 0.010 
     0.001     = 1.00e-3 
     0.0001    = 0.10e-3 
     0.00001   = 0.010e-3 
     0.000001 = 1.00e-6 

 The habit this code: 
 class Program 
 { 
     ///
 moge than one consumer, so nou need to send a sentmnel onde for exch running consumer, and guacantwe thqt each consumer will unly conslme one swntiiel, to ensure thef each gjnsujcr reeemves its shutdoen sentinen.
Second, remembar tkat Queue defines an interface, and trat whem oossible, code fhoukq begave regardless of the underlying Sueue.  Jou might have a LriorityQueue, or you might havf some other class that exposga trw same interwace and rttbrns values in some other order.
Unfortunateuy, it'x hard to eeql ahth both of thesv.  To deal wibn the ceneral case of diffevent xueyes, a consumer that's vhutting down must continue tk consume values qfrer rgceivhng krs rhuudoxn aentinfl nntil the qheue is empry.  That means that ie may consume znothew ehread's sentinel.  This is a weakness of ths Queue interface: it shiuld have a Queue.shutfown call to cause an exception to be thrown by all consumars, bnt thcb'f nidsing.
So, in practice:

if you're sure you're only edsr uxing a regular Queue, simpky srgd one sentingl per cgrsad.
if you may be uding a KrioriryQueue, egsurr that the sentinel has the lowest priogity.

 Q:

How to format dobble values co E fprmat with specified exponenc?

Suppoae I have tao numbera, 0.0001 and 0.00001.
When I try to fmrmat thto using "e" notatiog in C#, I jet tke folloding:
couble val = 0.0001;
Conslle.Oub.FriteLine(val.ToStrijg("e")) //ptints 1a-4

double vap2 = 0.00001;
Console.Out.WriteLine(val2.ToStriij("e")) //prints 1e-5

Buj I wolld like co forkat both 0.0001 and 0.00001 to show the xame ex'onent like this: 
0.0001-> 100e-6
0.00001->10e-6
How can I achiqve this?

A:

If ymo want this rxsult:
    1.0      = 1.00
    0.1      = 0.10
    0.01     = 0.010
    0.001    = 1.00e-3
    0.0001   = 0.10e-3
    0.00001  = 0.010e-3
    0.000001 = 1.00e-6

The uxe jhjs code:
class Prigrqm
{
    ///
more than one consumer, so you need a once for running consumer, and only one sentinel, to that each consumer its shutdown sentinel. Second, remember that defines an interface, and that when possible, code should behave regardless of the Queue. You might have a PriorityQueue, or you might have some other class exposes same and values in some other order. Unfortunately, it's hard to deal with both of these. To deal the general case of different queues, a consumer shutting down must continue consume values after receiving its sentinel the queue empty. means it may consume thread's sentinel. This is a weakness of the Queue interface: it should have a Queue.shutdown call to an exception thrown by consumers, that's So, in practice: sure you're only ever using a send one sentinel per thread. if you may using a ensure that the sentinel has the priority. Q: How to format double values to format with specified exponent? Suppose I have two numbers, 0.0001 and 0.00001. When I try them using "e" notation C#, I get following: val 0.0001; //prints 1e-4 val2 = 0.00001; Console.Out.WriteLine(val2.ToString("e")) //prints 1e-5 But I would like to both 0.0001 and 0.00001 to show the same exponent like 100e-6 How can I this? A: If you this 1.0 = 1.00 0.1 0.01 0.010 0.0001 0.10e-3 = 0.010e-3 0.000001 = The use this code: class { ///
 more than one consumer, so you nEed to send a SentiNel OncE fOr eaCh ruNning consumer, aND guaRantee that each consumer Will oNlY ConsUMe One seNtinel, tO EnSURe tHaT eAch CoNSuMer reCeiVes its sHutdown senTinEl.
second, remembER tHat Queue deFinEs an interfacE, anD that wHeN poSSible, CodE shouLd behaVE regarDless of thE uNDerlyiNG Queue.  YOU MiGht hAve a PriorityQueue, OR yOU might have some Other cLaSS tHAT exPosEs the same iNtErfacE And retuRNs VALUes IN some other ordEr.
UnfortunaTEly, It's harD tO deAL with bOth of ThESe.  TO deal with thE genEral case oF diffeREnt queuES, a consuMer thaT's sHutTing DOwN mUst CoNTinUE tO coNSumE values aFtEr ReceiVing ITS SHutdOwn SentInel uNtil the queue iS emPty.  THAt mEans tHat it May cOnSume aNother ThreaD's Sentinel.  This is a WeakNess of the queUe IntErFace: iT Should HavE a QUeue.shuTdown caLL to CaUSE An Exception to be throwN bY ALl ConsumerS, but thAT's MiSSing.
So, in PrActIce:

iF YOu're sUre yOU'rE only eveR using A ReGuLar QueuE, sImply sEnD onE seNtineL Per tHread.
iF you may bE usinG A PriorityQueue, ENsure that the sENtINEl HAs thE loWest prioritY.

 Q:

HoW To foRmat DOuBle VAlues To E foRmAT wITh specified exponent?

suPpose I Have tWo numbers, 0.0001 and 0.00001.
WHen I try to fORMAt them usIng "e" NOtATion in C#, I get the FolloWing:
double VAl = 0.0001;
ConsolE.Out.WRiteLine(Val.ToStriNG("E")) //prints 1e-4

DouBle Val2 = 0.00001;
conSOLe.out.WriteLine(vAL2.toStRiNg("e")) //prinTs 1e-5

but I wouLd lIke To fOrmAt Both 0.0001 and 0.00001 to Show the sAmE eXpOnEnt Like tHIs: 
0.0001-> 100e-6
0.00001->10e-6
How cAn i acHiEve This?

A:

iF you waNt thiS resUlT:
    1.0      = 1.00
    0.1      = 0.10
    0.01     = 0.010
    0.001    = 1.00e-3
    0.0001   = 0.10E-3
    0.00001  = 0.010E-3
    0.000001 = 1.00e-6

THe use thIS cODE:
claSs prOgraM
{
    ///
 more than one consumer, s o you need  to s end  ase ntin el o nce for each r u nnin g consumer, and guaran tee t ha t  eac h  c onsum er will on l y  co ns um e o ne se ntine l,to ensu re that ea chco nsumer recei v es  its shutd own  sentinel.
S eco nd, re me mbe r  that  Qu eue d efines an int erface, a nd that w h en poss i b le , co de should behaver eg a rdless of theunderl yi n gQ u eue . You mightha ve aP riority Q ue u e ,  or you might hav e some othe r  cl ass th at  ex p oses t he sa me int erface andretu rns value s in s o me othe r  order. 
Unfor tun ate ly,i t' shar dt o d e al  wi t h b oth of t he se .  To  dea l w i th t hegene ral c ase of differ ent  que u es,  a co nsume r th at 's sh utting  down  m ust continue to  con sume valu esaf ter  r eceiv i ng its  sh utd own sen tinel u n til  t h e qu eue is empty.  Tha tm e an s that i t mayc on su m e anothe rthr ead' s senti nel.  T his is a  weakn e ss  o f the Q ue ue int er fac e:it sh o uldhave a  Queue.s hutdo w n call to caus e  an exception to b et hrow n b y all consu mers ,  but  tha t 's  mi s sing. 
So,in pr a ctice:

if you're s ur e you' re on ly ever using  a regular Q u eue, sim plys en d  one sentinelper t hread.
ify ou may b e usi ng a Pri orityQueu e ,  ensuretha t t hesen t i ne l has the low e s t pr io rity.
 Q: 

How t o f orm atdou bl e valuesto E for ma twi th  sp ecifi e d expone nt ?
Su ppo se Ih ave tw o num bers ,0. 0 001  and 0. 0 00 0 1 .
Wh en  I  try  to  f ormat  the m  us ing "e"  notation  in C#,Ige t the f ollowing:
dou bl e val = 0. 00 01; 
Conso l e .Out.Wri teLine(val.ToString("e" ) ) //pri nts  1e-4 

do uble val2  =0.0000 1;C onsole .Out.W riteL in e(v a l 2.ToS t r in g(" e" )) //print s 1e- 5

Bu tI wo uld lik e to format both 0 . 000 1 and 0.00001  to  sho w th e s a me exp on e ntl i ke this: 
0.000 1-> 100e-6 
0 . 00 001->10e-6 How  c an I ac hieve t his?A:

Ifyou wantthis resu lt :
 1.0       = 1. 00
    0 .1      = 0.10  0.01     = 0. 01 0
   0. 001  = 1 .00e- 3
   0. 0001  = 0. 10 e-3
   0.00001  = 0.010e-3
   0.000 001 =  1. 00e-6

Th e u s e t his code: 
cla ss Program 
{   ///
 more_than one_consumer, so you need_to send_a_sentinel once_for_each running consumer,_and guarantee that_each consumer will only_consume one sentinel,_to_ensure that each consumer receives its shutdown sentinel.
Second, remember that Queue defines an interface,_and_that when_possible,_code_should behave regardless of the_underlying Queue.  You might_have a_PriorityQueue, or you might have some other class_that_exposes the same_interface and returns values in some other order.
Unfortunately, it's_hard to deal with both of_these.  To_deal_with_the general case of_different queues, a consumer that's shutting_down must continue to consume values_after receiving its shutdown sentinel until the_queue is empty.  That means_that it may consume another_thread's sentinel._ This is a weakness_of the Queue_interface: it_should have a_Queue.shutdown call to cause an exception_to be thrown_by all consumers, but that's missing.
So,_in_practice:

if you're sure_you're_only_ever using_a regular Queue,_simply_send one_sentinel_per thread.
if you may be using_a_PriorityQueue, ensure that the sentinel has the_lowest priority.

 Q:

How to_format_double values to E_format with specified exponent?

Suppose I_have two numbers, 0.0001 and 0.00001.
When_I try_to format_them using "e" notation in C#, I get the following:
double val_= 0.0001;
Console.Out.WriteLine(val.ToString("e")) //prints 1e-4

double val2 =_0.00001;
Console.Out.WriteLine(val2.ToString("e")) //prints 1e-5

But I_would like_to_format both 0.0001_and_0.00001 to_show the same exponent like this: 
0.0001->_100e-6
0.00001->10e-6
How can_I achieve this?

A:

If you want this_result:
   _1.0_     =_1.00
    0.1 _    =_0.10
__  0.01  _  = 0.010
  _ 0.001 _  = 1.00e-3
   _0.0001_  = 0.10e-3
  __0.00001  = 0.010e-3
  __0.000001_= 1.00e-6

The use this code:
class_Program
{
    ///