It wasn’t funny when comedian Louis C.K. did it.

And it certainly isn’t funny when someone, already facing criminal charges, takes out his junk and masturbates in the presence of the person who is trying to defend him.

When Louis C.K. was outed for this despicable behavior, the consequences came fast and furious. His film release was delayed, and cable companies canceled lucrative deals.

It isn’t surprising that the comedian quickly admitted his wrongdoing.

“I can hardly wrap my head around the scope of hurt I brought on them,” Louis C.K. said in a statement after five women accused him of masturbating in front of them.

OPINION

But the men who are boldly whipping out their stuff and masturbating in front of female public defenders and law clerks, who are trying to put together a defense for some indefensible acts, don’t have anything to lose.

“They kind of exist to cause a ruckus and disrupt operations,” said Cara Smith, the chief policy adviser to Cook County Sheriff Tom Dart.

Last week, the Cook County Public Defender and Dart were slapped with lawsuits alleging the officials have “been aware of this offensive and dangerous conduct by detainees for more than two years but have knowingly permitted it to continue.”

There are internal disciplinary actions taken against the offenders, but those tools are “not sufficient,” Smith said.

“Once they know this disrupts operations, new offenders are doing it all the time. The reason they do it is because they can,” Smith told me.

Disciplinary actions include requiring the offender to wear a special jump suit, and handcuffing the offender when he is in the lockup. The victim can also ask that criminal charges be filed.

Unfortunately those deterrents haven’t worked, and the lewd incidents have increased.

“When female [Assistant Public Defenders] (APD’s) and law clerks are visiting their clients in lockup or in Divisions 9 and 10 of the Cook County Jail, male detainees regularly expose their penises to female APDs and law clerks, attempt and threaten to assault female APDs and law clerks and masturbate at female APDs and law clerks, often with their penises fully exposed . . .” according to the lawsuit.

It shouldn’t have to come to this.

The Cook County Sheriff’s Office tried to pass tougher legislation to address the “masturbation” problem, but got pushback from Cook County Public Defender’s office.

“We drafted a law that would have said in a custodial environment upon the second conviction, the person would have to register as a sex offender. The public defender’s office opposed it, and it did not move,” Smith told me.

In a written statement, a spokesman for the public defender’s office said: “The Public Defender cannot support legislation or measures that significantly increase penalties for detainees who engage in this behavior or that subject detainees to inhumane practices.”

But let’s think about who’s really being subjected to “inhumane treatment.”

There’s no way a woman lawyer, law student or any other jail employee should be threatened and sexually abused by people they are trying to help.

These detainees wouldn’t act like that around their mothers, or sisters, or aunts. They are acting out sexually around these females because they know they can get away with it.

To someone who is facing 10 years in prison, the threat of a Class A misdemeanor for masturbating in public isn’t a threat — it’s a joke.

Try leaving the masturbators locked up in their cells, handcuffed, while the female assistant public defender goes off to court to deal with never-ending continuances.

Because if these men really thought something real was about to happen with their cases, they are smart enough to keep their pants zipped.